ossl_i2c_ASN1_BIT_STRING(): Fix a possible heap buffer overflow
When data contains only zero values a buffer overflow happens. CLA: trivial Signed-off-by: Andrey Tsygunka <aitsygunka@yandex.ru> Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/26190)
This commit is contained in:
parent
53b34561b5
commit
bf2dea0e2c
@ -36,6 +36,10 @@ int ossl_i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
|
||||
if (a->data[len - 1])
|
||||
break;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
bits = 0;
|
||||
} else {
|
||||
j = a->data[len - 1];
|
||||
if (j & 0x01)
|
||||
bits = 0;
|
||||
@ -56,6 +60,7 @@ int ossl_i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
|
||||
else
|
||||
bits = 0; /* should not happen */
|
||||
}
|
||||
}
|
||||
} else
|
||||
bits = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user