diff mbox series

[04/13] simfs: Quiet sanitizer runtime error

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

Commit Message

Denis Kenzior Oct. 31, 2024, 10:06 p.m. UTC
The arguments passed into memcpy for src and 'n' are NULL pointer and 0
respectively.  Strictly speaking null pointers should not be passed to
memcpy, and this raises a sanitizer runtime error:
src/simfs.c:1057:2: runtime error: null pointer passed as argument 2, which is declared to never be null

Use the newly introduced l_memcpy function to avoid triggering the
sanitizers
---
 src/simfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/simfs.c b/src/simfs.c
index c86e8d11fd0b..7f0390032bf6 100644
--- a/src/simfs.c
+++ b/src/simfs.c
@@ -9,7 +9,6 @@ 
 #include <config.h>
 #endif
 
-#include <string.h>
 #include <stdio.h>
 
 #include <glib.h>
@@ -27,6 +26,8 @@ 
 #include "storage.h"
 #include "missing.h"
 
+#include <ell/ell.h>
+
 #define SIM_CACHE_MODE 0600
 #define SIM_CACHE_BASEPATH STORAGEDIR "/%s-%i"
 #define SIM_CACHE_VERSION SIM_CACHE_BASEPATH "/version"
@@ -1054,7 +1055,7 @@  int sim_fs_read(struct ofono_sim_context *context, int id,
 	op->num_bytes = num_bytes;
 	op->info_only = FALSE;
 	op->context = context;
-	memcpy(op->path, path, path_len);
+	l_memcpy(op->path, path, path_len);
 	op->path_len = path_len;
 
 	g_queue_push_tail(fs->op_q, op);