lib/util/asn1.c:969 runtime error: left shift of negative value -1
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
bool asn1_read_implicit_Integer(struct asn1_data *data, int *i)
{
uint8_t b;
+ uint32_t x = 0;
bool first_byte = true;
+
*i = 0;
while (!data->has_error && asn1_tag_remaining(data)>0) {
if (!asn1_read_uint8(data, &b)) return false;
if (first_byte) {
if (b & 0x80) {
- /* Number is negative.
- Set i to -1 for sign extend. */
- *i = -1;
+ /* Number is negative. */
+ x = (uint32_t)-1;
}
first_byte = false;
}
- *i = (*i << 8) + b;
+ x = (x << 8) + b;
}
+ *i = (int)x;
+
return !data->has_error;
}