diff mbox series

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

Message ID 10e7ffbc-2d79-f970-a55a-a219ebd32f24@huawei.com
State Superseded
Headers show
Series solve memory leak and check whether NULL pointer | expand

Commit Message

zhanchengbin Dec. 3, 2021, 6:27 a.m. UTC
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 <zhanchengbin1@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
  lib/ss/execute_cmd.c | 2 ++
  1 file changed, 2 insertions(+)

      i = really_execute_command(sci_idx, argc, &argp);
diff mbox series

Patch

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];