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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240829024446.3041-1-zhujun2@cmss.chinamobile.com>
Date: Wed, 28 Aug 2024 19:44:46 -0700
From: Zhu Jun <zhujun2@...s.chinamobile.com>
To: kys@...rosoft.com
Cc: haiyangz@...rosoft.com,
	wei.liu@...nel.org,
	decui@...rosoft.com,
	linux-hyperv@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	zhujun2@...s.chinamobile.com
Subject: [PATCH v2] tools/hv: Add memory allocation check in hv_fcopy_start

Added error handling for memory allocation failures
of file_name and path_name.

Signed-off-by: Zhu Jun <zhujun2@...s.chinamobile.com>
---
v1->v2:
	Add cleanup memory

 tools/hv/hv_fcopy_uio_daemon.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tools/hv/hv_fcopy_uio_daemon.c b/tools/hv/hv_fcopy_uio_daemon.c
index 3ce316cc9f97..0af47d88a377 100644
--- a/tools/hv/hv_fcopy_uio_daemon.c
+++ b/tools/hv/hv_fcopy_uio_daemon.c
@@ -296,6 +296,18 @@ static int hv_fcopy_start(struct hv_start_fcopy *smsg_in)
 	file_name = (char *)malloc(file_size * sizeof(char));
 	path_name = (char *)malloc(path_size * sizeof(char));
 
+    if (!file_name) {
+        free(file_name);
+        syslog(LOG_ERR, "Can't allocate file_name memory!");
+        exit(EXIT_FAILURE);
+    }
+
+    if (!path_name) {
+        free(path_name);
+        syslog(LOG_ERR, "Can't allocate path_name memory!");
+        exit(EXIT_FAILURE);
+    }
+
 	wcstoutf8(file_name, (__u16 *)in_file_name, file_size);
 	wcstoutf8(path_name, (__u16 *)in_path_name, path_size);
 
-- 
2.17.1




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ