lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230614150118.115208-1-cymi20@fudan.edu.cn>
Date:   Wed, 14 Jun 2023 08:01:18 -0700
From:   Chenyuan Mi <cymi20@...an.edu.cn>
To:     acme@...hat.com
Cc:     irogers@...gle.com, namhyung@...nel.org, leo.yan@...aro.org,
        linux-kernel@...r.kernel.org, Chenyuan Mi <cymi20@...an.edu.cn>
Subject: [PATCH] perf subcmd: Fix missing check for return value of malloc() in add_cmdname()

The malloc() function may return NULL when it fails,
which may cause null pointer deference in add_cmdname(),
add Null check for return value of malloc().

Found by our static analysis tool.

Signed-off-by: Chenyuan Mi <cymi20@...an.edu.cn>
---
 tools/lib/subcmd/help.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/lib/subcmd/help.c b/tools/lib/subcmd/help.c
index bf02d62a3b2b..510a3eccb60f 100644
--- a/tools/lib/subcmd/help.c
+++ b/tools/lib/subcmd/help.c
@@ -16,6 +16,8 @@
 void add_cmdname(struct cmdnames *cmds, const char *name, size_t len)
 {
 	struct cmdname *ent = malloc(sizeof(*ent) + len + 1);
+	if (!ent)
+		return;
 
 	ent->len = len;
 	memcpy(ent->name, name, len);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ