From 9d42645aa3be4ace399cf89a39cb9745733e5910 Mon Sep 17 00:00:00 2001 From: archipelago Date: Thu, 23 Apr 2026 13:02:01 -0400 Subject: [PATCH] fix(avatar): prevent u16 overflow panic when seed byte is large MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hue_color and accent_color computed (seed as u16) * 360, which overflows u16 when seed >= 182 — debug builds panicked, release wrapped silently. Widen to u32 before the multiplication. This also unblocks several identity_manager tests that constructed avatars through master_node_svg and were aborting on the panic. --- core/archipelago/src/avatar.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/archipelago/src/avatar.rs b/core/archipelago/src/avatar.rs index 8a69beb6..9d565a6a 100644 --- a/core/archipelago/src/avatar.rs +++ b/core/archipelago/src/avatar.rs @@ -18,12 +18,12 @@ use base64::Engine; /// Convert a byte to an HSL triple biased toward readable foregrounds on /// dark backgrounds (saturation 60–85%, lightness 52–70%). fn hue_color(seed: u8) -> String { - let hue = (seed as u16) * 360 / 256; + let hue = (seed as u32) * 360 / 256; format!("hsl({}, 72%, 60%)", hue) } fn accent_color(seed: u8) -> String { - let hue = (seed as u16) * 360 / 256; + let hue = (seed as u32) * 360 / 256; format!("hsl({}, 80%, 68%)", hue) }