[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220217092500.40525-2-lczerner@redhat.com>
Date: Thu, 17 Feb 2022 10:24:59 +0100
From: Lukas Czerner <lczerner@...hat.com>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 2/3] 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 adding SS_ET_ENOMEM error and
checking the return from malloc.
Signed-off-by: Lukas Czerner <lczerner@...hat.com>
---
lib/ss/execute_cmd.c | 2 ++
lib/ss/ss_err.et | 3 +++
2 files changed, 5 insertions(+)
diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c
index d443a468..0bcaa54d 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(SS_ET_ENOMEM);
for (i = 0; i <= argc; i++)
argp[i] = argv[i];
i = really_execute_command(sci_idx, argc, &argp);
diff --git a/lib/ss/ss_err.et b/lib/ss/ss_err.et
index 80e9dfa4..f7238da0 100644
--- a/lib/ss/ss_err.et
+++ b/lib/ss/ss_err.et
@@ -36,4 +36,7 @@ ec SS_ET_ESCAPE_DISABLED,
ec SS_ET_UNIMPLEMENTED,
"Sorry, this request is not yet implemented"
+ec SS_ET_ENOMEM,
+ "Not enough memory"
+
end
--
2.34.1
Powered by blists - more mailing lists