From 14cbff5edcfc9226eadde02c0139f94c8784c445 Mon Sep 17 00:00:00 2001 From: Deluan Date: Sat, 18 Jul 2026 00:12:22 -0400 Subject: [PATCH] fix(artwork): prevent 32-bit overflow in the decode pixel guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- core/artwork/blurhash_updater.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/artwork/blurhash_updater.go b/core/artwork/blurhash_updater.go index edcd0573a..e76430c76 100644 --- a/core/artwork/blurhash_updater.go +++ b/core/artwork/blurhash_updater.go @@ -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