krb5: mask integers to avoid unnecessary expansion

Sign-extension would expand the encoding of packed negative integers to one
greater than required.
This commit is contained in:
Luke Howard
2021-08-07 19:17:55 +10:00
parent 6554dc69b0
commit 9d16808515

View File

@@ -412,6 +412,8 @@ krb5_store_int(krb5_storage *sp,
return EINVAL;
if (BYTEORDER_IS_PACKED(sp)) {
size_t mask = ~0ULL >> (64 - len * 8);
value &= mask;
p += sizeof(v) - 1;
len = pack_int(p, value);
p = v + sizeof(v) - len;