fp6-img/aports/temp/modemmanager/0001-intel-XMM7360-fix-big-endian-handling-of-ASN-integer.patch

42 lines
1.7 KiB
Diff
Raw Permalink Normal View History

From 4b936ada44a0f6ccb02745e9452c2b4b2412341c Mon Sep 17 00:00:00 2001
From: Aelin <aelin@postmarketos.org>
Date: Thu, 11 Jun 2026 22:01:36 +0200
Subject: [PATCH] intel: XMM7360: fix big-endian handling of ASN integer output
xmm7360_byte_array_read_asn_int() previously always returned
*out_val from the union member `value.l`, regardless of the actual
integer size. On big-endian systems, this caused 1-byte or 2-byte
values to be shifted incorrectly (e.g., 1-byte value 0x01 became
0x01000000).
Fix this by selecting the union member that matches the ASN int type.
---
src/plugins/intel/mm-xmmrpc-xmm7360-protocol.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/plugins/intel/mm-xmmrpc-xmm7360-protocol.c b/src/plugins/intel/mm-xmmrpc-xmm7360-protocol.c
index dcf16280..82db189c 100644
--- a/src/plugins/intel/mm-xmmrpc-xmm7360-protocol.c
+++ b/src/plugins/intel/mm-xmmrpc-xmm7360-protocol.c
@@ -115,14 +115,10 @@ xmm7360_byte_array_read_asn_int (GByteArray *buf,
*out_arg = arg;
if (out_val) {
- /* If the ASN int is negative, we must convert a int8/int16
- * value to the appropriate u32 value to avoid returning a
- * positive 32-bit gint.
- */
- if ((arg.type == XMM7360_RPC_MSG_ARG_TYPE_BYTE) && (arg.value.b < 0))
- *out_val = (arg.value.b << 24) >> 24;
- else if ((arg.type == XMM7360_RPC_MSG_ARG_TYPE_SHORT) && (arg.value.s < 0))
- *out_val = (arg.value.s << 16) >> 16;
+ if (arg.type == XMM7360_RPC_MSG_ARG_TYPE_BYTE)
+ *out_val = arg.value.b;
+ else if (arg.type == XMM7360_RPC_MSG_ARG_TYPE_SHORT)
+ *out_val = arg.value.s;
else
*out_val = arg.value.l;
}
--
2.54.0