Thread (8 messages) 8 messages, 2 authors, 2021-12-03
STALE1656d

[PATCH 2/6] lib/ss: check whether argp is null before accessing it in ss_execute_command()

From: zhanchengbin <hidden>
Date: 2021-12-03 06:27:54
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

In ss_execute_command(), we should check whether argp is null before 
accessing it,
otherwise the null potinter dereference error may occur.

Signed-off-by: zhanchengbin <redacted>
Signed-off-by: Zhiqiang Liu <redacted>
---
  lib/ss/execute_cmd.c | 2 ++
  1 file changed, 2 insertions(+)
diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c
index d443a468..b6e4a5dc 100644
--- a/lib/ss/execute_cmd.c
+++ b/lib/ss/execute_cmd.c
@@ -171,6 +171,8 @@ int ss_execute_command(int sci_idx, register char 
*argv[])
      for (argp = argv; *argp; argp++)
          argc++;
      argp = (char **)malloc((argc+1)*sizeof(char *));
+    if (argp == NULL)
+        return (SS_ET_COMMAND_NOT_FOUND);
      for (i = 0; i <= argc; i++)
          argp[i] = argv[i];
      i = really_execute_command(sci_idx, argc, &argp);
-- 
2.23.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help