From 4fead86d247f0a5c61d57d3155e0580f8c01d9b0 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 7 Jan 2026 22:57:25 -0600 Subject: [PATCH] intel: XMM7360: better handling of silly ASN int sizes xmm7360_byte_array_read_asn_int() would keep bit-shifting a gint into oblivion if the int's size was > 32-bit. It also didn't handle size 0 ints at all, and while size 24 ints would get stuffed into a 32-bit variable those probably aren't a thing and if they actually are they should get specifically handled. Signed-off-by: Dan Williams --- src/plugins/intel/mm-xmmrpc-xmm7360-protocol.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel/mm-xmmrpc-xmm7360-protocol.c b/src/plugins/intel/mm-xmmrpc-xmm7360-protocol.c index 8de12652..336987fe 100644 --- a/src/plugins/intel/mm-xmmrpc-xmm7360-protocol.c +++ b/src/plugins/intel/mm-xmmrpc-xmm7360-protocol.c @@ -75,6 +75,10 @@ xmm7360_byte_array_read_asn_int (GByteArray *buf, } offset++; size = buf->data[offset++]; + if (size > 4 || size == 3) { + PARSE_ERROR ("unhandled int size %d", size); + return -1; + } /* read actual value byte by byte */ if (buf->len < offset + size) { @@ -88,15 +92,20 @@ xmm7360_byte_array_read_asn_int (GByteArray *buf, } if (out_arg) { - if (size == 0x01) { + if (size == 0x00) { + out_arg->type = XMM7360_RPC_MSG_ARG_TYPE_UNKNOWN; + } else if (size == 0x01) { out_arg->type = XMM7360_RPC_MSG_ARG_TYPE_BYTE; out_arg->value.b = (gint8) val; } else if (size == 0x02) { out_arg->type = XMM7360_RPC_MSG_ARG_TYPE_SHORT; out_arg->value.s = (gint16) val; - } else { + } else if (size == 0x04) { out_arg->type = XMM7360_RPC_MSG_ARG_TYPE_LONG; out_arg->value.l = (gint32) val; + } else { + /* size is validated above */ + g_assert_not_reached (); } }