[crypto] Remove harmless but technically undefined left shift

The unsigned 8-bit value from the keyUsage bit string is promoted to a
(signed) int before being shifted left by up to 24 bits, which is
technically undefined behaviour.

Explicitly cast the 8-bit value to an unsigned int before shifting, to
inhibit this class of false positive warning.  There is no difference
to the resulting object code.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2026-08-03 16:45:33 +01:00
parent 0471d6d131
commit 1475250140
+1 -1
View File
@@ -524,7 +524,7 @@ static int x509_parse_key_usage ( struct x509_certificate *cert,
if ( len > sizeof ( usage->bits ) )
len = sizeof ( usage->bits );
for ( i = 0 ; i < len ; i++ ) {
usage->bits |= ( *(bytes++) << ( 8 * i ) );
usage->bits |= ( ( ( unsigned ) *(bytes++) ) << ( 8 * i ) );
}
DBGC2 ( cert, "X509 %p key usage is %08x\n", cert, usage->bits );