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
@@ -453,7 +453,8 @@ entry2mit_string_int(krb5_context context, krb5_storage *sp, hdb_entry *ent)
|
||||
unsigned char *ptr;
|
||||
|
||||
ptr = (unsigned char *)&last_pw_chg;
|
||||
val = ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);
|
||||
val = ((unsigned long)ptr[3] << 24) | (ptr[2] << 16)
|
||||
| (ptr[1] << 8) | ptr[0];
|
||||
d.data = &val;
|
||||
d.length = sizeof (last_pw_chg);
|
||||
sz = append_string(context, sp, "\t%u\t%u\t",
|
||||
|
Reference in New Issue
Block a user