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
@@ -132,7 +132,7 @@ _gss_import_export_name(OM_uint32 *minor_status,
|
||||
p += t;
|
||||
len -= t;
|
||||
|
||||
t = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
|
||||
t = ((unsigned long)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
|
||||
/* p += 4; // we're done using `p' now */
|
||||
len -= 4;
|
||||
|
||||
|
@@ -572,7 +572,7 @@ gsskrb5_extract_authtime_from_sec_context(OM_uint32 *minor_status,
|
||||
|
||||
{
|
||||
unsigned char *buf = data_set->elements[0].value;
|
||||
*authtime = (buf[3] <<24) | (buf[2] << 16) |
|
||||
*authtime = ((unsigned long)buf[3] <<24) | (buf[2] << 16) |
|
||||
(buf[1] << 8) | (buf[0] << 0);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user