Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/su Don't free memory that was succesfully passed to ...



details:   https://anonhg.NetBSD.org/src/rev/a3b2f7641915
branches:  trunk
changeset: 757899:a3b2f7641915
user:      tron <tron%NetBSD.org@localhost>
date:      Sat Oct 02 10:55:36 2010 +0000

description:
Don't free memory that was succesfully passed to putenv(3) which takes
ownership of the memory.

diffstat:

 usr.bin/su/su_pam.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r 9537404ef4a5 -r a3b2f7641915 usr.bin/su/su_pam.c
--- a/usr.bin/su/su_pam.c       Sat Oct 02 10:51:07 2010 +0000
+++ b/usr.bin/su/su_pam.c       Sat Oct 02 10:55:36 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: su_pam.c,v 1.15 2008/07/21 14:19:26 lukem Exp $        */
+/*     $NetBSD: su_pam.c,v 1.16 2010/10/02 10:55:36 tron Exp $ */
 
 /*
  * Copyright (c) 1988 The Regents of the University of California.
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)su.c       8.3 (Berkeley) 4/2/94";*/
 #else
-__RCSID("$NetBSD: su_pam.c,v 1.15 2008/07/21 14:19:26 lukem Exp $");
+__RCSID("$NetBSD: su_pam.c,v 1.16 2010/10/02 10:55:36 tron Exp $");
 #endif
 #endif /* not lint */
 
@@ -469,8 +469,8 @@
                                 * how could we get untrusted data here?
                                 */
                                for (envitem = pamenv; *envitem; envitem++) {
-                                       (void)putenv(*envitem);
-                                       free(*envitem);
+                                       if (putenv(*envitem) == -1)
+                                               free(*envitem);
                                }
 
                                free(pamenv);



Home | Main Index | Thread Index | Old Index