Date: Tue, 2 Mar 1999 09:55:47 +1100 From: Peter Jeremy <jeremyp@gsmx07.alcatel.com.au> To: FreeBSD-gnats-submit@FreeBSD.ORG Cc: jeremyp@gsmx07.alcatel.com.au Subject: bin/10342: putenv(3) unnecessarily calls strdup/free Message-ID: <99Mar2.094435est.40323@border.alcanet.com.au>
next in thread | raw e-mail | index | archive | help
>Number: 10342 >Category: bin >Synopsis: putenv(3) unnecessarily calls strdup/free >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 1 15:00:00 PST 1999 >Closed-Date: >Last-Modified: >Originator: Peter Jeremy >Release: FreeBSD 3.0-CURRENT i386 >Organization: Alcatel Australia Limited >Environment: putenv.c 1.1 >Description: putenv(3) uses strdup to create a local copy of the passed environment string so it can replace the `=' with NUL to pass a NUL-terminated name to setenv(3). Since setenv(3) will accept a `='-terminated name (this is documented, as well as actual behaviour), this is unnecessary. >How-To-Repeat: Study manual page and code for setenv(3). >Fix: Change putenv.c to: int putenv(str) const char *str; { char *equal; if ((equal = index(str, '=')) == NULL) { return (-1); } return (setenv(str, equal + 1, 1)); } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?99Mar2.094435est.40323>