diff mbox series

[03/13] simutil: Return early if file is not found

Message ID 20241031220638.1582166-3-denkenz@gmail.com (mailing list archive)
State Accepted
Commit b59850d0a4e332b766c1521cd0644aa9e5808856
Headers show
Series [01/13] qmi: validate TLV length | expand

Commit Message

Denis Kenzior Oct. 31, 2024, 10:06 p.m. UTC
Certain Elementary Files are only present on SIM (2G) or USIMs (3G/4G).
If the file is not relevant to a given generation, its parent2g or
parent3g member will be set to 0.  Return early if the file is found to
be irrelevant for a given phase.  This also fixes a runtime sanitizer
warning:

src/simutil.c:1345:10: runtime error: null pointer passed as argument 1, which is declared to never be null
---
 src/simutil.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/simutil.c b/src/simutil.c
index a504e9aa8e3b..0fafcb7f77de 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -1302,7 +1302,7 @@  unsigned int sim_ef_db_get_path_2g(unsigned short id, unsigned char out_path[])
 
 	info = bsearch(GUINT_TO_POINTER((unsigned int) id), ef_db, nelem,
 				sizeof(struct sim_ef_info), find_ef_by_id);
-	if (info == NULL)
+	if (info == NULL || !info->parent2g)
 		return 0;
 
 	path[i++] = info->parent2g & 0xff;
@@ -1335,7 +1335,7 @@  unsigned int sim_ef_db_get_path_3g(unsigned short id, unsigned char out_path[])
 
 	info = bsearch(GUINT_TO_POINTER((unsigned int) id), ef_db, nelem,
 				sizeof(struct sim_ef_info), find_ef_by_id);
-	if (info == NULL)
+	if (info == NULL || !info->parent3g)
 		return 0;
 
 	path[i++] = info->parent3g & 0xff;