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]
Date:	Tue, 01 Apr 2008 23:06:41 +0800 (CST)
From:	WANG Cong <xiyou.wangcong@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	akpm@...l.org, jdike@...toit.com,
	user-mode-linux-devel@...ts.sourceforge.net
Subject: [Patch] arch/um/os-Linux/main.c: Fix memory leaks.


This patch fixes possible memory leaks in the main() function of
arch/um/os-Linux/main.c.

Cc: jdike@...toit.com
Signed-off-by: WANG Cong <wangcong@...ux.org>

---

Index: linux-2.6/arch/um/os-Linux/main.c
===================================================================
--- linux-2.6.orig/arch/um/os-Linux/main.c
+++ linux-2.6/arch/um/os-Linux/main.c
@@ -113,14 +113,10 @@ static void setup_env_path(void)
 
 extern void scan_elf_aux( char **envp);
 
-int __init main(int argc, char **argv, char **envp)
+static char** dup_argv(int argc, char **argv)
 {
+	int i;
 	char **new_argv;
-	int ret, i, err;
-
-	set_stklim();
-
-	setup_env_path();
 
 	new_argv = malloc((argc + 1) * sizeof(char *));
 	if (new_argv == NULL) {
@@ -135,6 +131,28 @@ int __init main(int argc, char **argv, c
 		}
 	}
 	new_argv[argc] = NULL;
+	return new_argv;
+}
+
+static void free_argv(int argc, char **argv)
+{
+	int i;
+	for (i = 0; i < argc; i++) {
+		free(argv[i]);
+	}
+	free(argv);
+}
+
+int __init main(int argc, char **argv, char **envp)
+{
+	char **new_argv;
+	int ret, i, err;
+
+	set_stklim();
+
+	setup_env_path();
+
+	new_argv = dup_argv(argc, argv);
 
 	/*
 	 * Allow these signals to bring down a UML if all other
@@ -185,6 +203,7 @@ int __init main(int argc, char **argv, c
 		perror("Failed to exec kernel");
 		ret = 1;
 	}
+	free_argv(argc, new_argv);
 	printf("\n");
 	return uml_exitcode;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ