DragonFly BSD
DragonFly submit List (threaded) for 2005-09
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[PATCH] setenv|putenv rc checking (libexec)


From: Alexey Slynko <slynko@xxxxxxxxx>
Date: Thu, 29 Sep 2005 15:43:46 +0400

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();
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 */
 
@@ -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;
@@ -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;
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
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 */
 


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