CBL-Mariner/SPECS/azure-iot-sdk-c/CVE-2024-21646.patch

23 строки
1.5 KiB
Diff

diff -ruN a/uamqp/src/amqpvalue.c b/uamqp/src/amqpvalue.c
--- a/uamqp/src/amqpvalue.c 2024-01-16 16:24:25.728073998 -0800
+++ b/uamqp/src/amqpvalue.c 2024-01-17 04:45:07.632022782 -0800
@@ -5912,7 +5912,17 @@
}
else
{
- internal_decoder_data->decode_to_value->value.binary_value.bytes = (unsigned char*)malloc((size_t)internal_decoder_data->decode_to_value->value.binary_value.length + 1);
+ size_t malloc_size = (size_t)internal_decoder_data->decode_to_value->value.binary_value.length + 1;
+ if (malloc_size == 0)
+ {
+ internal_decoder_data->decode_to_value->value.binary_value.bytes = NULL;
+ LogError("Invalid binary_value size exceeded max allocation");
+ }
+ else
+ {
+ internal_decoder_data->decode_to_value->value.binary_value.bytes = (unsigned char*)malloc(malloc_size);
+ }
+
if (internal_decoder_data->decode_to_value->value.binary_value.bytes == NULL)
{
/* Codes_SRS_AMQPVALUE_01_326: [If any allocation failure occurs during decoding, amqpvalue_decode_bytes shall fail and return a non-zero value.] */