mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-21 16:55:38 +03:00
allow overflow in imaging
This commit is contained in:
parent
666b8bc4f2
commit
8db3d6b700
1 changed files with 16 additions and 92 deletions
|
@ -399,25 +399,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
g16 := uint16(s[1])
|
||||
b16 := uint16(s[2])
|
||||
a16 := uint16(a)
|
||||
|
||||
d0 := r16 * 0xff / a16
|
||||
if d0 > math.MaxUint8 {
|
||||
panic("overflow d0")
|
||||
}
|
||||
|
||||
d1 := g16 * 0xff / a16
|
||||
if d1 > math.MaxUint8 {
|
||||
panic("overflow d1")
|
||||
}
|
||||
|
||||
d2 := b16 * 0xff / a16
|
||||
if d2 > math.MaxUint8 {
|
||||
panic("overflow d2")
|
||||
}
|
||||
|
||||
d[0] = uint8(d0) // #nosec G115 -- Just checked.
|
||||
d[1] = uint8(d1) // #nosec G115 -- Just checked.
|
||||
d[2] = uint8(d2) // #nosec G115 -- Just checked.
|
||||
d[0] = uint8(r16 * 0xff / a16) // #nosec G115 -- Overflow desired.
|
||||
d[1] = uint8(g16 * 0xff / a16) // #nosec G115 -- Overflow desired.
|
||||
d[2] = uint8(b16 * 0xff / a16) // #nosec G115 -- Overflow desired.
|
||||
d[3] = a
|
||||
}
|
||||
j += 4
|
||||
|
@ -447,25 +431,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
g32 := uint32(s[2])<<8 | uint32(s[3])
|
||||
b32 := uint32(s[4])<<8 | uint32(s[5])
|
||||
a32 := uint32(s[6])<<8 | uint32(s[7])
|
||||
|
||||
d0 := (r32 * 0xffff / a32) >> 8
|
||||
if d0 > math.MaxUint8 {
|
||||
panic("overflow d0")
|
||||
}
|
||||
|
||||
d1 := (g32 * 0xffff / a32) >> 8
|
||||
if d1 > math.MaxUint8 {
|
||||
panic("overflow d1")
|
||||
}
|
||||
|
||||
d2 := (b32 * 0xffff / a32) >> 8
|
||||
if d2 > math.MaxUint8 {
|
||||
panic("overflow d2")
|
||||
}
|
||||
|
||||
d[0] = uint8(d0) // #nosec G115 -- Just checked.
|
||||
d[1] = uint8(d1) // #nosec G115 -- Just checked.
|
||||
d[2] = uint8(d2) // #nosec G115 -- Just checked.
|
||||
d[0] = uint8((r32 * 0xffff / a32) >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[1] = uint8((g32 * 0xffff / a32) >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[2] = uint8((b32 * 0xffff / a32) >> 8) // #nosec G115 -- Overflow desired.
|
||||
}
|
||||
d[3] = a
|
||||
j += 4
|
||||
|
@ -546,9 +514,6 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
} else {
|
||||
r = ^(r >> 31)
|
||||
}
|
||||
if r > math.MaxUint8 {
|
||||
panic("overflow r")
|
||||
}
|
||||
|
||||
g := yy1 - 22554*cb1 - 46802*cr1
|
||||
if uint32(g)&0xff000000 == 0 {
|
||||
|
@ -556,9 +521,6 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
} else {
|
||||
g = ^(g >> 31)
|
||||
}
|
||||
if g > math.MaxUint8 {
|
||||
panic("overflow g")
|
||||
}
|
||||
|
||||
b := yy1 + 116130*cb1
|
||||
if uint32(b)&0xff000000 == 0 {
|
||||
|
@ -566,14 +528,11 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
} else {
|
||||
b = ^(b >> 31)
|
||||
}
|
||||
if b > math.MaxUint8 {
|
||||
panic("overflow b")
|
||||
}
|
||||
|
||||
d := dst[j : j+4 : j+4]
|
||||
d[0] = uint8(r) // #nosec G115 -- Just checked.
|
||||
d[1] = uint8(g) // #nosec G115 -- Just checked.
|
||||
d[2] = uint8(b) // #nosec G115 -- Just checked.
|
||||
d[0] = uint8(r) // #nosec G115 -- Overflow desired.
|
||||
d[1] = uint8(g) // #nosec G115 -- Overflow desired.
|
||||
d[2] = uint8(b) // #nosec G115 -- Overflow desired.
|
||||
d[3] = 0xff
|
||||
|
||||
iy++
|
||||
|
@ -610,24 +569,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
d := dst[j : j+4 : j+4]
|
||||
switch a16 {
|
||||
case 0xffff:
|
||||
d0 := r16 >> 8
|
||||
if d0 > math.MaxUint8 {
|
||||
panic("overflow d0")
|
||||
}
|
||||
|
||||
d1 := g16 >> 8
|
||||
if d1 > math.MaxUint8 {
|
||||
panic("overflow d1")
|
||||
}
|
||||
|
||||
d2 := b16 >> 8
|
||||
if d2 > math.MaxUint8 {
|
||||
panic("overflow d2")
|
||||
}
|
||||
|
||||
d[0] = uint8(d0) // #nosec G115 -- Just checked.
|
||||
d[1] = uint8(d1) // #nosec G115 -- Just checked.
|
||||
d[2] = uint8(d2) // #nosec G115 -- Just checked.
|
||||
d[0] = uint8(r16 >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[1] = uint8(g16 >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[2] = uint8(b16 >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[3] = 0xff
|
||||
case 0:
|
||||
d[0] = 0
|
||||
|
@ -635,30 +579,10 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
|
|||
d[2] = 0
|
||||
d[3] = 0
|
||||
default:
|
||||
d0 := ((r16 * 0xffff) / a16) >> 8
|
||||
if d0 > math.MaxUint8 {
|
||||
panic("overflow d0")
|
||||
}
|
||||
|
||||
d1 := ((g16 * 0xffff) / a16) >> 8
|
||||
if d1 > math.MaxUint8 {
|
||||
panic("overflow d1")
|
||||
}
|
||||
|
||||
d2 := ((b16 * 0xffff) / a16) >> 8
|
||||
if d2 > math.MaxUint8 {
|
||||
panic("overflow d2")
|
||||
}
|
||||
|
||||
d3 := a16 >> 8
|
||||
if d3 > math.MaxUint8 {
|
||||
panic("overflow d3")
|
||||
}
|
||||
|
||||
d[0] = uint8(d0) // #nosec G115 -- Just checked.
|
||||
d[1] = uint8(d1) // #nosec G115 -- Just checked.
|
||||
d[2] = uint8(d2) // #nosec G115 -- Just checked.
|
||||
d[3] = uint8(d3) // #nosec G115 -- Just checked.
|
||||
d[0] = uint8(((r16 * 0xffff) / a16) >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[1] = uint8(((g16 * 0xffff) / a16) >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[2] = uint8(((b16 * 0xffff) / a16) >> 8) // #nosec G115 -- Overflow desired.
|
||||
d[3] = uint8(a16 >> 8) // #nosec G115 -- Overflow desired.
|
||||
}
|
||||
j += 4
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue