diff options
Diffstat (limited to 'internal/media')
-rw-r--r-- | internal/media/ffmpeg.go | 4 | ||||
-rw-r--r-- | internal/media/imaging.go | 40 | ||||
-rw-r--r-- | internal/media/refetch.go | 7 | ||||
-rw-r--r-- | internal/media/util.go | 2 |
4 files changed, 26 insertions, 27 deletions
diff --git a/internal/media/ffmpeg.go b/internal/media/ffmpeg.go index 4baa3dbe5..f1c277934 100644 --- a/internal/media/ffmpeg.go +++ b/internal/media/ffmpeg.go @@ -556,10 +556,10 @@ func (res *ffprobeResult) Process() (*result, error) { if p := strings.SplitN(str, "/", 2); len(p) == 2 { n, _ := strconv.ParseUint(p[0], 10, 32) d, _ := strconv.ParseUint(p[1], 10, 32) - num, den = uint32(n), uint32(d) + num, den = uint32(n), uint32(d) // #nosec G115 -- ParseUint is configured to check } else { n, _ := strconv.ParseUint(p[0], 10, 32) - num = uint32(n) + num = uint32(n) // #nosec G115 -- ParseUint is configured to check } // Set final divised framerate. diff --git a/internal/media/imaging.go b/internal/media/imaging.go index a9f73a066..6a0fa694c 100644 --- a/internal/media/imaging.go +++ b/internal/media/imaging.go @@ -399,9 +399,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) { g16 := uint16(s[1]) b16 := uint16(s[2]) a16 := uint16(a) - d[0] = uint8(r16 * 0xff / a16) - d[1] = uint8(g16 * 0xff / a16) - d[2] = uint8(b16 * 0xff / a16) + 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 @@ -431,9 +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]) - d[0] = uint8((r32 * 0xffff / a32) >> 8) - d[1] = uint8((g32 * 0xffff / a32) >> 8) - d[2] = uint8((b32 * 0xffff / a32) >> 8) + 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 @@ -509,30 +509,30 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) { cr1 := int32(img.Cr[ic]) - 128 r := yy1 + 91881*cr1 - if uint32(r)&0xff000000 == 0 { + if uint32(r)&0xff000000 == 0 { //nolint:gosec r >>= 16 } else { r = ^(r >> 31) } g := yy1 - 22554*cb1 - 46802*cr1 - if uint32(g)&0xff000000 == 0 { + if uint32(g)&0xff000000 == 0 { //nolint:gosec g >>= 16 } else { g = ^(g >> 31) } b := yy1 + 116130*cb1 - if uint32(b)&0xff000000 == 0 { + if uint32(b)&0xff000000 == 0 { //nolint:gosec b >>= 16 } else { b = ^(b >> 31) } d := dst[j : j+4 : j+4] - d[0] = uint8(r) - d[1] = uint8(g) - d[2] = uint8(b) + 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++ @@ -569,9 +569,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) { d := dst[j : j+4 : j+4] switch a16 { case 0xffff: - d[0] = uint8(r16 >> 8) - d[1] = uint8(g16 >> 8) - d[2] = uint8(b16 >> 8) + 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 @@ -579,10 +579,10 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) { d[2] = 0 d[3] = 0 default: - d[0] = uint8(((r16 * 0xffff) / a16) >> 8) - d[1] = uint8(((g16 * 0xffff) / a16) >> 8) - d[2] = uint8(((b16 * 0xffff) / a16) >> 8) - d[3] = uint8(a16 >> 8) + 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 } @@ -617,7 +617,7 @@ func clampFloat(x float64) uint8 { return 255 } if v > 0 { - return uint8(v) + return uint8(v) // #nosec G115 -- Just checked. } return 0 } diff --git a/internal/media/refetch.go b/internal/media/refetch.go index 5531f6d97..c467333c9 100644 --- a/internal/media/refetch.go +++ b/internal/media/refetch.go @@ -49,9 +49,6 @@ func (m *Manager) RefetchEmojis(ctx context.Context, domain string, dereferenceM refetchIDs []string ) - // Get max supported remote emoji media size. - maxsz := config.GetMediaEmojiRemoteMaxSize() - // page through emojis 20 at a time, looking for those with missing images for { // Fetch next block of emojis from database @@ -111,8 +108,10 @@ func (m *Manager) RefetchEmojis(ctx context.Context, domain string, dereferenceM continue } + // Get max supported remote emoji media size. + maxsz := int64(config.GetMediaEmojiRemoteMaxSize()) // #nosec G115 -- Already validated. dataFunc := func(ctx context.Context) (reader io.ReadCloser, err error) { - return dereferenceMedia(ctx, emojiImageIRI, int64(maxsz)) + return dereferenceMedia(ctx, emojiImageIRI, maxsz) } processingEmoji, err := m.UpdateEmoji(ctx, emoji, dataFunc, AdditionalEmojiInfo{ diff --git a/internal/media/util.go b/internal/media/util.go index 538d6f572..f6bf06260 100644 --- a/internal/media/util.go +++ b/internal/media/util.go @@ -145,7 +145,7 @@ func drainToTmp(rc io.ReadCloser) (string, error) { // Check to see if limit was reached, // (produces more useful error messages). if lr != nil && lr.N <= 0 { - err := fmt.Errorf("reached read limit %s", bytesize.Size(limit)) + err := fmt.Errorf("reached read limit %s", bytesize.Size(limit)) // #nosec G115 -- Just logging return path, gtserror.SetLimitReached(err) } |