[PATCH 1/2] speedupmodem: ussd: ensure ussd content fits in buffer
"Sicelo A. Mhlongo" <[email protected]> Mon, 16 Dec 2024 13:00:20 +0200
| Newsgroups | dev.linux.lists.ofono |
|---|---|
| Message-ID | <[email protected]> |
Additional fix for CVE-2024-7539
---
drivers/speedupmodem/ussd.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/speedupmodem/ussd.c b/drivers/speedupmodem/ussd.c
index aafa4bc9..7d2df790 100644
--- a/drivers/speedupmodem/ussd.c
+++ b/drivers/speedupmodem/ussd.c
@@ -37,7 +37,7 @@ static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd)
int status;
int dcs = 0;
const char *content;
- unsigned char msg[160];
+ unsigned char msg[160] = {0};
const unsigned char *msg_ptr = NULL;
long msg_len;
@@ -54,6 +54,10 @@ static void cusd_parse(GAtResult *result, struct ofono_ussd *ussd)
g_at_result_iter_next_number(&iter, &dcs);
+ if (strlen(content) > sizeof(msg) * 2)
+ goto out;
+ }
+
msg_ptr = decode_hex_own_buf(content, -1, &msg_len, 0, msg);
out:
--
2.45.2