From: Lukas Czerner Date: Thu, 17 Feb 2022 09:24:59 +0000 (+0100) Subject: libss: fix possible NULL pointer dereferece on allocation failure X-Git-Tag: v1.46.6-rc1~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a282671a02e8fffa04ac0f9db7982fd6bb0a0916;p=thirdparty%2Fe2fsprogs.git libss: fix possible NULL pointer dereferece on allocation failure 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 Signed-off-by: Theodore Ts'o --- diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c index d443a4685..2e2c8cfa0 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) + return(ENOMEM); for (i = 0; i <= argc; i++) argp[i] = argv[i]; i = really_execute_command(sci_idx, argc, &argp);