From 305df050d02aea8532f7625d6642685aa530f9b0 Mon Sep 17 00:00:00 2001
From: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Date: Tue, 3 Dec 2024 21:43:51 +0200
Subject: [PATCH] Fix CVE-2024-7547

CVE: CVE-2024-7547
Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/ofono/ofono.git/commit/?id=305df050d02aea8532f7625d6642685aa530f9b0]
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
---
 src/smsutil.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/smsutil.c b/src/smsutil.c
index def47e8..f79f59d 100644
--- a/src/smsutil.c
+++ b/src/smsutil.c
@@ -1475,6 +1475,9 @@ static gboolean decode_command(const unsigned char *pdu, int len,
 	if ((len - offset) < out->command.cdl)
 		return FALSE;
 
+	if (out->command.cdl > sizeof(out->command.cd))
+		return FALSE;
+
 	memcpy(out->command.cd, pdu + offset, out->command.cdl);
 
 	return TRUE;
-- 
2.25.1

