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 <dan@ioncontrol.co>
This commit is contained in:
Dan Williams
2026-05-24 08:33:48 -05:00
parent 3f7b39075c
commit 4fead86d24
+11 -2
View File
@@ -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 ();
}
}