[PATCH] setenv|putenv rc checking (libexec)
Simon 'corecode' Schubert
corecode at fs.ei.tum.de
Thu Sep 29 05:06:02 PDT 2005
Alexey Slynko wrote:
------------------------------------------------------------------------
Index: ftpd/popen.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/libexec/ftpd/popen.c,v
retrieving revision 1.2
diff -u -r1.2 popen.c
--- ftpd/popen.c 17 Jun 2003 04:27:07 -0000 1.2
+++ ftpd/popen.c 29 Sep 2005 01:30:14 -0000
@@ -146,7 +146,8 @@
closelog();
/* Trigger to sense new /etc/localtime after chroot */
if (getenv("TZ") == NULL) {
- setenv("TZ", "", 0);
+ if (setenv("TZ", "", 0) == ENOMEM)
+ err(1, "setenv: cannot set TZ");
tzset();
unsetenv("TZ");
tzset();
not sure if this is an error condition.
Index: telnetd/state.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/libexec/telnetd/state.c,v
retrieving revision 1.2
diff -u -r1.2 state.c
--- telnetd/state.c 17 Jun 2003 04:27:08 -0000 1.2
+++ telnetd/state.c 29 Sep 2005 01:38:20 -0000
@@ -35,6 +35,8 @@
* $DragonFly: src/libexec/telnetd/state.c,v 1.2 2003/06/17 04:27:08 dillon Exp $
*/
+#include <err.h>
+#include <errno.h>
#include <stdarg.h>
#include "telnetd.h"
@@ -1162,7 +1164,8 @@
return;
settimer(xdisplocsubopt);
subpointer[SB_LEN()] = '\0';
- (void)setenv("DISPLAY", (char *)subpointer, 1);
+ if (setenv("DISPLAY", (char *)subpointer, 1) == ENOMEM)
+ err(1, "setenv: cannot set DISPLAY=%s", (char *)subpointer);
break;
} /* end of case TELOPT_XDISPLOC */
no error, but warning, i'd say
@@ -1327,8 +1330,10 @@
case NEW_ENV_VAR:
case ENV_USERVAR:
*cp = '\0';
- if (valp)
- (void)setenv(varp, valp, 1);
+ if (valp) {
+ if (setenv(varp, valp, 1) == ENOMEM)
+ err(1, "setenv: cannot set %s=%s", varp, valp);
+ }
else
unsetenv(varp);
cp = varp = (char *)subpointer;
dito
@@ -1346,8 +1351,10 @@
}
}
*cp = '\0';
- if (valp)
- (void)setenv(varp, valp, 1);
+ if (valp) {
+ if (setenv(varp, valp, 1) == ENOMEM)
+ err(1, "setenv: cannot set %s=%s", varp, valp);
+ }
else
unsetenv(varp);
break;
missing the context here, but i think warning condition as well
Index: telnetd/sys_term.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/libexec/telnetd/sys_term.c,v
retrieving revision 1.2
diff -u -r1.2 sys_term.c
--- telnetd/sys_term.c 17 Jun 2003 04:27:08 -0000 1.2
+++ telnetd/sys_term.c 29 Sep 2005 01:39:03 -0000
@@ -37,6 +37,7 @@
#include <sys/types.h>
#include <sys/tty.h>
+#include <err.h>
#include <libutil.h>
#include <stdlib.h>
#include <utmp.h>
@@ -1026,11 +1027,15 @@
* "real" or "kludge" if we are operating in either
* real or kludge linemode.
*/
- if (lmodetype == REAL_LINEMODE)
- setenv("LINEMODE", "real", 1);
+ if (lmodetype == REAL_LINEMODE) {
+ if (setenv("LINEMODE", "real", 1) == ENOMEM)
+ err(1, "setenv: cannot set LINEMODE=real");
+ }
# ifdef KLUDGELINEMODE
- else if (lmodetype == KLUDGE_LINEMODE || lmodetype == KLUDGE_OK)
- setenv("LINEMODE", "kludge", 1);
+ else if (lmodetype == KLUDGE_LINEMODE || lmodetype == KLUDGE_OK) {
+ if (setenv("LINEMODE", "kludge", 1) == ENOMEM)
+ err(1, "setenv: cannot set LINEMODE=kludge");
+ }
# endif
#endif
#ifdef BFTPDAEMON
warning
Index: telnetd/telnetd.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/libexec/telnetd/telnetd.c,v
retrieving revision 1.2
diff -u -r1.2 telnetd.c
--- telnetd/telnetd.c 17 Jun 2003 04:27:08 -0000 1.2
+++ telnetd/telnetd.c 29 Sep 2005 01:37:51 -0000
@@ -590,7 +590,8 @@
*/
*user_name = 0;
level = getterminaltype(user_name);
- setenv("TERM", terminaltype ? terminaltype : "network", 1);
+ if (setenv("TERM", terminaltype ? terminaltype : "network", 1) == ENOMEM)
+ err(1, "setenv: cannot set TERM=%s", terminaltype ? terminaltype : "network");
telnet(net, pty, remote_hostname); /* begin server process */
warning
--
Serve - BSD +++ RENT this banner advert +++ ASCII Ribbon /"\
Work - Mac +++ space for low $$$ NOW!1 +++ Campaign \ /
Party Enjoy Relax | http://dragonflybsd.org Against HTML \
Dude 2c 2 the max ! http://golden-apple.biz Mail + News / \
More information about the Submit
mailing list