virt: nsm: decode all short CBOR array lengths
Subsystems (2)
PATCH 1/1 virt: nsm: decode all short CBOR array lengths
CBOR encodes array lengths from zero through 23 directly in the initial byte. The decoder only handled 23, leaving array_len uninitialized for every other short-form length.
Accept the full short-form range and reject reserved additional-information values above the supported 64-bit encoding.
Signed-off-by Yousef Alhouseen <[email protected]>
--- drivers/misc/nsm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/misc/nsm.c +3 -1
@@ -105,6 +105,8 @@ static int cbor_object_get_array(u8 *cbor_object, size_t cbor_object_size, u8 **return -EFAULT ; cbor_short_size = (cbor_object[0 ] &0x1F ); +if (cbor_short_size >CBOR_LONG_SIZE_U64 ) +return -EFAULT ;/* Decoding byte array length */ array_offset =CBOR_HEADER_SIZE_SHORT ;
@@ -117,7 +119,7 @@ static int cbor_object_get_array(u8 *cbor_object, size_t cbor_object_size, u8 ** array_len_p = &cbor_object[1 ];switch (cbor_short_size) { -case CBOR_SHORT_SIZE_MAX_VALUE :/* short encoding */ + case 0 ... CBOR_SHORT_SIZE_MAX_VALUE: /* short encoding */ array_len = cbor_short_size;break ;case CBOR_LONG_SIZE_U8 :
Signature · 1 line
2.54.0