Message-Id: <199908091237.MAA44712@out4.ibm.net> From: "Mark E." To: Eli Zaretskii , djgpp-workers AT delorie DOT com Date: Mon, 9 Aug 1999 08:38:02 -0400 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: suggestion for getenv.c References: <199908082020 DOT UAA80886 AT out1 DOT ibm DOT net> In-reply-to: X-mailer: Pegasus Mail for Win32 (v3.11) Reply-To: djgpp-workers AT delorie DOT com > Why should we silently ignore a NULL pointer? If anything, we should > set errno to EFAULT. `environ' being NULL is a valid situation, but > passing a NULL `name' is not. > Fair enough. Here's a revised version: *** src/libc/ansi/stdlib/getenv.c.orig Fri Nov 24 22:21:18 1995 --- src/libc/ansi/stdlib/getenv.c Mon Aug 9 08:34:30 1999 *************** *** 1,6 **** --- 1,8 ---- + /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ #include #include + #include extern char **environ; *************** char * *** 8,13 **** --- 10,21 ---- getenv(const char *name) { int i; + + if (name == 0) + { + errno = EFAULT; + return 0; + } if (environ == 0) return 0; --- Mark Elbrecht, snowball3 AT bigfoot DOT com http://snowball.frogspace.net/