Module Name: src Committed By: enami Date: Mon Nov 1 02:41:27 UTC 2010
Modified Files: src/lib/libc/stdlib: getenv.c Log Message: Double the array only when really necessary. Otherwise memory will be exhausted if user modifies the variable envrion itself repeatedly.. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/lib/libc/stdlib/getenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/stdlib/getenv.c diff -u src/lib/libc/stdlib/getenv.c:1.26 src/lib/libc/stdlib/getenv.c:1.27 --- src/lib/libc/stdlib/getenv.c:1.26 Sun Oct 24 17:53:27 2010 +++ src/lib/libc/stdlib/getenv.c Mon Nov 1 02:41:27 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: getenv.c,v 1.26 2010/10/24 17:53:27 tron Exp $ */ +/* $NetBSD: getenv.c,v 1.27 2010/11/01 02:41:27 enami Exp $ */ /* * Copyright (c) 1987, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)getenv.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: getenv.c,v 1.26 2010/10/24 17:53:27 tron Exp $"); +__RCSID("$NetBSD: getenv.c,v 1.27 2010/11/01 02:41:27 enami Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -120,8 +120,7 @@ return 0; /* Make sure we at least double the size of the arrays. */ - new_len = (environ_malloced_len >= 16) ? - (environ_malloced_len << 1) : 16; + new_len = environ_malloced_len >= 16 ? environ_malloced_len : 16; while (new_len < required_len) new_len = new_len << 1;