344 su fails to check malloc's return value
Reviewed by: Albert Lee <
[email protected]>
Reviewed by: Enrico Papi <
[email protected]>
Reviewed by: Garrett D'Amore <
[email protected]>
Approved by: Garrett D'Amore <
[email protected]>
--- a/usr/src/cmd/su/su.c Mon May 14 15:11:16 2012 -0500
+++ b/usr/src/cmd/su/su.c Tue May 15 12:48:44 2012 -0700
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
@@ -535,6 +536,10 @@
malloc(strlen(initenv[j])
+ strlen(initvar)
+ 2);
+ if (var == NULL) {
+ perror("malloc");
+ exit(4);
+ }
(void) strcpy(var, initenv[j]);
(void) strcat(var, "=");
(void) strcat(var, initvar);