Whamcloud - gitweb
libss: fix possible NULL pointer dereferece on allocation failure
authorLukas Czerner <lczerner@redhat.com>
Thu, 17 Feb 2022 09:24:59 +0000 (10:24 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 28 Apr 2022 17:12:47 +0000 (13:12 -0400)
Currently in ss_execute_command() we're missng a check to see if the
memory allocation was succesful. Fix it by checking the return from
malloc and returning ENOMEM if it had failed.

[ Removed addition of the SS_ET_ENOMEM entry to the the libss error
  table.  -TYT ]

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ss/execute_cmd.c

index d443a46..2e2c8cf 100644 (file)
@@ -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)
+               return(ENOMEM);
        for (i = 0; i <= argc; i++)
                argp[i] = argv[i];
        i = really_execute_command(sci_idx, argc, &argp);