From: Lukas Czerner <lczerner@redhat.com>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH 2/3] libss: fix possible NULL pointer dereferece on allocation failure
Date: Thu, 17 Feb 2022 10:24:59 +0100 [thread overview]
Message-ID: <20220217092500.40525-2-lczerner@redhat.com> (raw)
In-Reply-To: <20220217092500.40525-1-lczerner@redhat.com>
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@redhat.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
next prev parent reply other threads:[~2022-02-17 9:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 9:24 [PATCH 1/3] resize2fs: remove unused variable 'c' Lukas Czerner
2022-02-17 9:24 ` Lukas Czerner [this message]
2022-02-17 9:25 ` [PATCH 3/3] e2fsprogs: use mallinfo2 instead of mallinfo if available Lukas Czerner
2022-02-28 23:49 ` Andreas Dilger
2022-02-28 23:50 ` Andreas Dilger
2022-02-28 23:51 ` [PATCH 1/3] resize2fs: remove unused variable 'c' Andreas Dilger
2022-04-28 17:16 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220217092500.40525-2-lczerner@redhat.com \
--to=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).