From: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
To: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Cc: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>,
GNU/Weeb Mailing List <gwml@vger.gnuweeb.org>,
Tea Inside Mailing List <timl@vger.teainside.org>,
Ammar Faizi <ammarfaizi2@gmail.com>,
Louvian Lyndal <louvianlyndal@gmail.com>,
Michael Arminto <kohaku.mski@gmail.com>
Subject: [PATCH teavpn2 2/3] net: iface: Fix a potential NULL pointer dereference
Date: Fri, 27 May 2022 00:02:26 +0000 [thread overview]
Message-ID: <20220527000227.1253934-3-alviro.iskandar@gnuweeb.org> (raw)
In-Reply-To: <20220527000227.1253934-1-alviro.iskandar@gnuweeb.org>
The malloc() call in escapeshellarg() doesn't have a NULL check. This
results in a potential NULL pointer dereference. Fix this by checking
the return value of malloc(). Just return NULL directly if we hit the
ENOMEM case.
Fixes: 0cfd7f8b60a09000a4257015b592e79b0bd8b8bd ("net: rewire iface support for linux")
Cc: Ammar Faizi <ammarfaizi2@gmail.com>
Cc: Louvian Lyndal <louvianlyndal@gmail.com>
Cc: Michael Arminto <kohaku.mski@gmail.com>
Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
---
src/teavpn2/net/linux/iface.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/teavpn2/net/linux/iface.c b/src/teavpn2/net/linux/iface.c
index 010e195..a77c1c8 100644
--- a/src/teavpn2/net/linux/iface.c
+++ b/src/teavpn2/net/linux/iface.c
@@ -107,11 +107,14 @@ __cold static noinline char *escapeshellarg(char *alloc, const char *str,
size_t x;
char *cmd;
- if (alloc == NULL)
+ if (alloc == NULL) {
/* Worst case */
cmd = (char *)malloc((sizeof(char) * l * 4) + 1);
- else
+ if (!cmd)
+ return NULL;
+ } else {
cmd = alloc;
+ }
#ifdef WIN32
cmd[y++] = '"';
--
Alviro Iskandar Setiawan
next prev parent reply other threads:[~2022-05-27 0:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 0:02 [PATCH teavpn2 0/3] teavpn2 fixes Alviro Iskandar Setiawan
2022-05-27 0:02 ` [PATCH teavpn2 1/3] allocator: Fix `@errno` value when overflow Alviro Iskandar Setiawan
2022-05-27 0:02 ` Alviro Iskandar Setiawan [this message]
2022-05-27 0:02 ` [PATCH teavpn2 3/3] arch/linux: syscall: Fix retval checking in libc syscall Alviro Iskandar Setiawan
2022-05-27 0:14 ` [PATCH teavpn2 0/3] teavpn2 fixes Ammar Faizi
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=20220527000227.1253934-3-alviro.iskandar@gnuweeb.org \
--to=alviro.iskandar@gnuweeb.org \
--cc=ammarfaizi2@gmail.com \
--cc=ammarfaizi2@gnuweeb.org \
--cc=gwml@vger.gnuweeb.org \
--cc=kohaku.mski@gmail.com \
--cc=louvianlyndal@gmail.com \
--cc=timl@vger.teainside.org \
/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