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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230614145247.114100-1-cymi20@fudan.edu.cn>
Date:   Wed, 14 Jun 2023 07:52:47 -0700
From:   Chenyuan Mi <cymi20@...an.edu.cn>
To:     leo.yan@...aro.org
Cc:     acme@...hat.com, linux-kernel@...r.kernel.org,
        Chenyuan Mi <cymi20@...an.edu.cn>
Subject: [PATCH] perf subcmd: Fix missing check for return value of malloc()

The malloc() function may return NULL when it fails,
which may cause null pointer deference in prepare_exec_cmd(),
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/exec-cmd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/lib/subcmd/exec-cmd.c b/tools/lib/subcmd/exec-cmd.c
index 5dbea456973e..2e45c0cd4b68 100644
--- a/tools/lib/subcmd/exec-cmd.c
+++ b/tools/lib/subcmd/exec-cmd.c
@@ -168,6 +168,8 @@ static const char **prepare_exec_cmd(const char **argv)
 	for (argc = 0; argv[argc]; argc++)
 		; /* just counting */
 	nargv = malloc(sizeof(*nargv) * (argc + 2));
+	if (!nargv)
+		return NULL;
 
 	nargv[0] = subcmd_config.exec_name;
 	for (argc = 0; argv[argc]; argc++)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ