prevent unintended sign extension errors
When an unsigned char is shifted << 24 bits its type will be promoted to signed 32-bits. If the value is then assigned to an unsigned 64-bit value sign extension will occur. Prevent the unwanted sign extension by explicitly casting the value to unsigned long before shifting. Change-Id: Iabeac0f17dc3229a2dc89abe71960a8ffbf523f8
This commit is contained in:

committed by
Jeffrey Altman

parent
3707c52ea7
commit
f341fa7721
@@ -142,7 +142,7 @@ parse_name(const unsigned char *p, size_t len,
|
||||
/* MECHNAME_LEN */
|
||||
if (len < 4)
|
||||
return 1;
|
||||
l = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
|
||||
l = (unsigned long)p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
|
||||
len -= 4;
|
||||
p += 4;
|
||||
|
||||
|
Reference in New Issue
Block a user