mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-01 07:21:17 +00:00
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:
parent
ebaf804dbf
commit
14cbff5edc
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user