base32_decode: avoid shifting into the sign bit

While this won't do harm on systems that do 2's completement,
it triggers the compilers' undefined-behavior sanitizer and
fixes sanitizer error such as the one below (where the 1694... will
vary) and is distracting while debugging.

dnssec.c:1427:12: runtime error: left shift of 1694604366 by 1 places
cannot be represented in type 'int'
This commit is contained in:
Matthias Andree
2026-01-31 23:22:30 +01:00
committed by Simon Kelley
parent 870f14108f
commit e9f400dd37

View File

@@ -1423,7 +1423,10 @@ static int base32_decode(char *in, unsigned char *out)
oc |= 1; oc |= 1;
mask = mask >> 1; mask = mask >> 1;
if (((++on) & 7) == 0) if (((++on) & 7) == 0)
*p++ = oc; {
*p++ = oc;
oc = 0;
}
oc = oc << 1; oc = oc << 1;
} }
} }