Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/stdlib Set errno to ENOENT if we reject the environ...



details:   https://anonhg.NetBSD.org/src/rev/33ff6e230f19
branches:  trunk
changeset: 758747:33ff6e230f19
user:      tron <tron%NetBSD.org@localhost>
date:      Sun Nov 14 20:37:02 2010 +0000

description:
Set errno to ENOENT if we reject the environment variable name in
getenv_r() instead of leaving it unchanged.

diffstat:

 lib/libc/stdlib/getenv.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (30 lines):

diff -r 4c86404d7f2d -r 33ff6e230f19 lib/libc/stdlib/getenv.c
--- a/lib/libc/stdlib/getenv.c  Sun Nov 14 19:49:16 2010 +0000
+++ b/lib/libc/stdlib/getenv.c  Sun Nov 14 20:37:02 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getenv.c,v 1.33 2010/11/14 18:11:43 tron Exp $ */
+/*     $NetBSD: getenv.c,v 1.34 2010/11/14 20:37:02 tron 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.33 2010/11/14 18:11:43 tron Exp $");
+__RCSID("$NetBSD: getenv.c,v 1.34 2010/11/14 20:37:02 tron Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -87,8 +87,10 @@
        _DIAGASSERT(name != NULL);
 
        l_name = __envvarnamelen(name, false);
-       if (l_name == 0)
+       if (l_name == 0) {
+               errno = ENOENT;
                return -1;
+       }
 
        rv = -1;
        if (__readlockenv()) {



Home | Main Index | Thread Index | Old Index