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-prev] [day] [month] [year] [list]
Message-Id: <20240514205525.28342-2-ant.v.moryakov@gmail.com>
Date: Tue, 14 May 2024 23:55:25 +0300
From: Anton <ant.v.moryakov@...il.com>
To: stephen@...workplumber.org
Cc: netdev@...r.kernel.org,
	Anton <ant.v.moryakov@...il.com>
Subject: [PATCH] utils.c: Fixed potential memory leak in getcmdline function

The getcmdline function in utils.c dynamically allocates memory for the line1 variable using getline function but fails to free it in case of an error. Added a check to free the allocated memory if getline returns a negative value, preventing potential memory leaks.

Signed-off-by: Anton ant.v.moryakov@...il.com
---
 lib/utils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/utils.c b/lib/utils.c
index 051cff9c..d46b47fb 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -1339,6 +1339,9 @@ static ssize_t getcmdline(char **linep, size_t *lenp, FILE *in)
 		cc1 = getline(&line1, &len1, in);
 		if (cc1 < 0) {
 			fprintf(stderr, "Missing continuation line\n");
+			if (line1) {
+				free(line1); 
+			}
 			return cc1;
 		}
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ