fix(artwork): prevent 32-bit overflow in the decode pixel guard

cfg.Width*cfg.Height in int overflows on 32-bit builds (armv5/v6/v7, 386) for
dimensions like 50000x50000, going negative and bypassing maxDecodePixels — the
exact bomb the guard exists to reject. Multiply in int64.
This commit is contained in:
Deluan 2026-07-18 00:12:22 -04:00
parent ebaf804dbf
commit 14cbff5edc

View File

@ -71,7 +71,8 @@ func (u *blurHashUpdater) update(ctx context.Context, artID model.ArtworkID, dat
hash := u.cachedHash(artID, sum)
if hash == "" {
cfg, _, err := image.DecodeConfig(bytes.NewReader(data))
if err != nil || cfg.Width*cfg.Height > maxDecodePixels {
// int64: on 32-bit builds the pixel product can overflow int and bypass the guard.
if err != nil || int64(cfg.Width)*int64(cfg.Height) > maxDecodePixels {
// Undecodable or oversized served bytes are not proof of change; keep the stored hash.
log.Trace(ctx, "BlurHash: skipping served bytes", "artID", artID, "width", cfg.Width, "height", cfg.Height, err)
return