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] [thread-next>] [day] [month] [year] [list]
Message-Id: <1389106394-31898-10-git-send-email-tytso@mit.edu>
Date:	Tue,  7 Jan 2014 09:53:14 -0500
From:	Theodore Ts'o <tytso@....edu>
To:	Ext4 Developers List <linux-ext4@...r.kernel.org>
Cc:	Theodore Ts'o <tytso@....edu>
Subject: [PATCH 10/10] libss: fix memory leak if realloc() fails in ss_parse()

Addresses-Coverity-Id: #709491

Signed-off-by: "Theodore Ts'o" <tytso@....edu>
---
 lib/ss/parse.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/lib/ss/parse.c b/lib/ss/parse.c
index e2928e2..45a2de0 100644
--- a/lib/ss/parse.c
+++ b/lib/ss/parse.c
@@ -45,7 +45,7 @@ enum parse_mode { WHITESPACE, TOKEN, QUOTED_STRING };
 
 char **ss_parse(int sci_idx, register char *line_ptr, int *argc_ptr)
 {
-    register char **argv, *cp;
+    register char **argv, **new_argv, *cp;
     register int argc;
     register enum parse_mode parse_mode;
 
@@ -78,7 +78,13 @@ char **ss_parse(int sci_idx, register char *line_ptr, int *argc_ptr)
 		/* go to quoted-string mode */
 		parse_mode = QUOTED_STRING;
 		cp = line_ptr++;
-		argv = NEW_ARGV (argv, argc);
+		new_argv = NEW_ARGV (argv, argc);
+		if (new_argv == NULL) {
+			free(argv);
+			*argc_ptr = 0;
+			return NULL;
+		}
+		argv = new_argv;
 		argv[argc++] = cp;
 		argv[argc] = NULL;
 	    }
@@ -86,11 +92,13 @@ char **ss_parse(int sci_idx, register char *line_ptr, int *argc_ptr)
 		/* random-token mode */
 		parse_mode = TOKEN;
 		cp = line_ptr;
-		argv = NEW_ARGV (argv, argc);
+		new_argv = NEW_ARGV (argv, argc);
 		if (argv == NULL) {
-			*argc_ptr = errno;
-			return argv;
+			free(argv);
+			*argc_ptr = 0;
+			return NULL;
 		}
+		argv = new_argv;
 		argv[argc++] = line_ptr;
 		argv[argc] = NULL;
 	    }
-- 
1.8.5.rc3.362.gdf10213

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ