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

[PATCHES] setenv(putenv) patchset


From: Alexey Slynko <slynko@xxxxxxxxx>
Date: Tue, 16 Aug 2005 23:08:55 +0400

Hi,

this patchset check result of setenv(putenv) function.
It doesn't patch /contrib,/crypto and /sys subtrees.
Also it dowsn't patch /lib/libutil/login_class.c, because I have no idea, how it can be done



? usr.bin/make/make
? usr.bin/make/make.1.gz
Index: bin/date/date.c
===================================================================
RCS file: /home/dcvs/src/bin/date/date.c,v
retrieving revision 1.13
diff -u -r1.13 date.c
--- bin/date/date.c	20 Jul 2005 19:51:56 -0000	1.13
+++ bin/date/date.c	16 Aug 2005 17:37:29 -0000
@@ -117,7 +117,9 @@
 			set_timezone = 1;
 			break;
 		case 'u':		/* do everything in UTC */
-			setenv("TZ", "UTC0", 1);
+			if (setenv("TZ", "UTC0", 1) == -1) {
+				err(1, "setenv: TZ");
+			}
 			break;
 		case 'v':
 			v = vary_append(v, optarg);
Index: bin/df/df.c
===================================================================
RCS file: /home/dcvs/src/bin/df/df.c,v
retrieving revision 1.5
diff -u -r1.5 df.c
--- bin/df/df.c	7 Nov 2004 20:54:51 -0000	1.5
+++ bin/df/df.c	16 Aug 2005 17:37:29 -0000
@@ -144,11 +144,13 @@
 		case 'b':
 				/* FALLTHROUGH */
 		case 'P':
-			putenv("BLOCKSIZE=512");
+			if (putenv("BLOCKSIZE=512") == -1)
+				err(1, "putenv: BLOCKSIZE=512");
 			hflag = 0;
 			break;
 		case 'g':
-			putenv("BLOCKSIZE=1g");
+			if (putenv("BLOCKSIZE=1g") == -1)
+				err(1, "putenv: BLOCKSIZE=1g");
 			hflag = 0;
 			break;
 		case 'H':
@@ -163,7 +165,8 @@
 			iflag = 1;
 			break;
 		case 'k':
-			putenv("BLOCKSIZE=1k");
+			if (putenv("BLOCKSIZE=1k") == -1)
+				err(1, "putenv: BLOCKSIZE=1k");
 			hflag = 0;
 			break;
 		case 'l':
@@ -172,7 +175,8 @@
 			vfslist = makevfslist(makenetvfslist());
 			break;
 		case 'm':
-			putenv("BLOCKSIZE=1m");
+			if (putenv("BLOCKSIZE=1m") == -1)
+				err(1, "putenv: BLOCKSIZE=1m");
 			hflag = 0;
 			break;
 		case 'n':
Index: bin/ls/ls.c
===================================================================
RCS file: /home/dcvs/src/bin/ls/ls.c,v
retrieving revision 1.6
diff -u -r1.6 ls.c
--- bin/ls/ls.c	7 Nov 2004 20:54:51 -0000	1.6
+++ bin/ls/ls.c	16 Aug 2005 17:37:30 -0000
@@ -204,7 +204,8 @@
 			fts_options |= FTS_COMFOLLOW;
 			break;
 		case 'G':
-			setenv("CLICOLOR", "", 1);
+			if (setenv("CLICOLOR", "", 1) == -1)
+				err(1, "setenv: CLICOLOR");
 			break;
 		case 'L':
 			fts_options &= ~FTS_PHYSICAL;
Index: bin/sh/var.c
===================================================================
RCS file: /home/dcvs/src/bin/sh/var.c,v
retrieving revision 1.8
diff -u -r1.8 var.c
--- bin/sh/var.c	19 Apr 2005 05:18:19 -0000	1.8
+++ bin/sh/var.c	16 Aug 2005 17:37:30 -0000
@@ -41,6 +41,9 @@
 #include <unistd.h>
 #include <stdlib.h>
 
+#include <err.h>
+#include <errno.h>
+
 /*
  * Shell variables.
  */
@@ -316,7 +319,8 @@
 			if (vp == &vmpath || (vp == &vmail && ! mpathset()))
 				chkmail(1);
 			if ((vp->flags & VEXPORT) && localevar(s)) {
-				putenv(s);
+				if (putenv(s) == -1)
+					error("putenv: %s: %s", s, strerror(errno));
 				setlocale(LC_ALL, "");
 			}
 			INTON;
@@ -332,7 +336,8 @@
 	INTOFF;
 	*vpp = vp;
 	if ((vp->flags & VEXPORT) && localevar(s)) {
-		putenv(s);
+		if (putenv(s) == -1)
+			error("putenv: %s: %s", s, strerror(errno));
 		setlocale(LC_ALL, "");
 	}
 	INTON;
@@ -553,7 +558,8 @@
 
 						vp->flags |= flag;
 						if ((vp->flags & VEXPORT) && localevar(vp->text)) {
-							putenv(vp->text);
+							if (putenv(vp->text) == -1)
+								error("putenv: %s: %s", vp->text, strerror(errno));
 							setlocale(LC_ALL, "");
 						}
 						goto found;
Index: libexec/ftpd/popen.c
===================================================================
RCS file: /home/dcvs/src/libexec/ftpd/popen.c,v
retrieving revision 1.2
diff -u -r1.2 popen.c
--- libexec/ftpd/popen.c	17 Jun 2003 04:27:07 -0000	1.2
+++ libexec/ftpd/popen.c	16 Aug 2005 17:37:43 -0000
@@ -42,6 +42,7 @@
 #include <sys/wait.h>
 #include <netinet/in.h>
 
+#include <err.h>
 #include <errno.h>
 #include <glob.h>
 #include <signal.h>
@@ -146,7 +147,8 @@
 			closelog();
 			/* Trigger to sense new /etc/localtime after chroot */
 			if (getenv("TZ") == NULL) {
-				setenv("TZ", "", 0);
+				if (setenv("TZ", "", 0) == -1)
+					err(1, "setenv: TZ");
 				tzset();
 				unsetenv("TZ");
 				tzset();
Index: libexec/telnetd/state.c
===================================================================
RCS file: /home/dcvs/src/libexec/telnetd/state.c,v
retrieving revision 1.2
diff -u -r1.2 state.c
--- libexec/telnetd/state.c	17 Jun 2003 04:27:08 -0000	1.2
+++ libexec/telnetd/state.c	16 Aug 2005 17:37:43 -0000
@@ -1162,7 +1162,10 @@
 		return;
 	settimer(xdisplocsubopt);
 	subpointer[SB_LEN()] = '\0';
-	(void)setenv("DISPLAY", (char *)subpointer, 1);
+	if (setenv("DISPLAY", (char *)subpointer, 1) == -1) {
+		syslog(LOG_ERR, "setenv: DISPLAY: %m");
+		exit(1);
+	}
 	break;
     }  /* end of case TELOPT_XDISPLOC */
 
@@ -1327,9 +1330,12 @@
 		case NEW_ENV_VAR:
 		case ENV_USERVAR:
 			*cp = '\0';
-			if (valp)
-				(void)setenv(varp, valp, 1);
-			else
+			if (valp) {
+				if (setenv(varp, valp, 1) == 1) {
+					syslog(LOG_ERR, "setenv: %s: %m", varp);
+					exit(1);
+				}
+			} else
 				unsetenv(varp);
 			cp = varp = (char *)subpointer;
 			valp = 0;
@@ -1346,9 +1352,12 @@
 		}
 	}
 	*cp = '\0';
-	if (valp)
-		(void)setenv(varp, valp, 1);
-	else
+	if (valp) {
+		if (setenv(varp, valp, 1) == -1) {
+			syslog(LOG_ERR, "setenv: %s: %m", varp);
+			exit(1);
+		}
+	} else
 		unsetenv(varp);
 	break;
     }  /* end of case TELOPT_NEW_ENVIRON */
Index: libexec/telnetd/sys_term.c
===================================================================
RCS file: /home/dcvs/src/libexec/telnetd/sys_term.c,v
retrieving revision 1.2
diff -u -r1.2 sys_term.c
--- libexec/telnetd/sys_term.c	17 Jun 2003 04:27:08 -0000	1.2
+++ libexec/telnetd/sys_term.c	16 Aug 2005 17:37:43 -0000
@@ -1026,12 +1026,19 @@
 	 * "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) == -1) {
+			syslog(LOG_ERR, "setenv: LINEMODE: %m");
+			exit(1);
+		}
 # 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) == -1) {
+			syslog(LOG_ERR, "setenv: LINEMODE: %m");
+			exit(1);
+		}
 # endif
+	}
 #endif
 #ifdef	BFTPDAEMON
 	/*
Index: libexec/telnetd/telnetd.c
===================================================================
RCS file: /home/dcvs/src/libexec/telnetd/telnetd.c,v
retrieving revision 1.2
diff -u -r1.2 telnetd.c
--- libexec/telnetd/telnetd.c	17 Jun 2003 04:27:08 -0000	1.2
+++ libexec/telnetd/telnetd.c	16 Aug 2005 17:37:43 -0000
@@ -590,7 +590,10 @@
 	 */
 	*user_name = 0;
 	level = getterminaltype(user_name);
-	setenv("TERM", terminaltype ? terminaltype : "network", 1);
+	if (setenv("TERM", terminaltype ? terminaltype : "network", 1) == -1) {
+		syslog(LOG_ERR, "setenv: TERM: %m");
+		_exit(1);
+	}
 
 	telnet(net, pty, remote_hostname);	/* begin server process */
 
Index: usr.bin/du/du.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/du/du.c,v
retrieving revision 1.7
diff -u -r1.7 du.c
--- usr.bin/du/du.c	1 Jan 2005 23:02:42 -0000	1.7
+++ usr.bin/du/du.c	16 Aug 2005 17:37:53 -0000
@@ -155,13 +155,15 @@
 				cflag = 1;
 				break;
 			case 'h':
-				putenv("BLOCKSIZE=512");
+				if (putenv("BLOCKSIZE=512") == -1)
+					err(1, "putenv: BLOCKSIZE=512");
 				hflag = 1;
 				valp = vals_base2;
 				break;
 			case 'k':
 				hflag = 0;
-				putenv("BLOCKSIZE=1024");
+				if (putenv("BLOCKSIZE=1024") == -1)
+					err(1, "putenv: BLOCKSIZE=1024");
 				break;
 			case 'r':		 /* Compatibility. */
 				break;
Index: usr.bin/fetch/fetch.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/fetch/fetch.c,v
retrieving revision 1.5
diff -u -r1.5 fetch.c
--- usr.bin/fetch/fetch.c	4 Jan 2005 23:08:13 -0000	1.5
+++ usr.bin/fetch/fetch.c	16 Aug 2005 17:37:53 -0000
@@ -906,7 +906,8 @@
 	if (v_tty)
 		fetchAuthMethod = query_auth;
 	if (N_filename != NULL)
-		setenv("NETRC", N_filename, 1);
+		if (setenv("NETRC", N_filename, 1) == -1)
+			err(1, "setenv: NETRC");
 
 	while (argc) {
 		if ((p = strrchr(*argv, '/')) == NULL)
Index: usr.bin/ldd/ldd.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/ldd/ldd.c,v
retrieving revision 1.5
diff -u -r1.5 ldd.c
--- usr.bin/ldd/ldd.c	24 Jul 2005 15:04:56 -0000	1.5
+++ usr.bin/ldd/ldd.c	16 Aug 2005 17:37:54 -0000
@@ -98,11 +98,14 @@
 #endif
 
 	/* ld.so magic */
-	setenv("LD_TRACE_LOADED_OBJECTS", "1", 1);
+	if (setenv("LD_TRACE_LOADED_OBJECTS", "1", 1) == -1)
+		err(1, "setenv: LD_TRACE_LOADED_OBJECTS");
 	if (fmt1)
-		setenv("LD_TRACE_LOADED_OBJECTS_FMT1", fmt1, 1);
+		if (setenv("LD_TRACE_LOADED_OBJECTS_FMT1", fmt1, 1) == -1)
+			err(1, "setenv: LD_TRACE_LOADED_OBJECTS_FMT1");
 	if (fmt2)
-		setenv("LD_TRACE_LOADED_OBJECTS_FMT2", fmt2, 1);
+		if (setenv("LD_TRACE_LOADED_OBJECTS_FMT2", fmt2, 1) == -1)
+			err(1, "setenv: LD_TRACE_LOADED_OBJECTS_FMT2");
 
 	rval = 0;
 	for ( ;  argc > 0;  argc--, argv++) {
@@ -180,7 +183,8 @@
 			continue;
 		}
 
-		setenv("LD_TRACE_LOADED_OBJECTS_PROGNAME", *argv, 1);
+		if (setenv("LD_TRACE_LOADED_OBJECTS_PROGNAME", *argv, 1) == -1)
+			err(1, "setenv: LD_TRACE_LOADED_OBJECTS_PROGNAME");
 		if (fmt1 == NULL && fmt2 == NULL)
 			/* Default formats */
 			printf("%s:\n", *argv);
Index: usr.bin/limits/limits.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/limits/limits.c,v
retrieving revision 1.4
diff -u -r1.4 limits.c
--- usr.bin/limits/limits.c	12 Jan 2005 01:20:26 -0000	1.4
+++ usr.bin/limits/limits.c	16 Aug 2005 17:37:54 -0000
@@ -434,7 +434,8 @@
 
 	/* set leading environment variables, like eval(1) */
 	while (*argv && (p = strchr(*argv, '=')))
-	    (void)setenv(*argv++, ++p, 1);
+	    if (setenv(*argv++, ++p, 1) == -1)
+		err(1, "setenv: %s", *argv);
 
 	/* Set limits */
 	for (rcswhich = 0; rcswhich < RLIM_NLIMITS; rcswhich++) {
Index: usr.bin/login/login.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/login/login.c,v
retrieving revision 1.5
diff -u -r1.5 login.c
--- usr.bin/login/login.c	13 Jul 2005 12:34:22 -0000	1.5
+++ usr.bin/login/login.c	16 Aug 2005 17:37:54 -0000
@@ -656,16 +656,37 @@
 		exit(1);
 	}
 
-	(void)setenv("SHELL", pwd->pw_shell, 1);
-	(void)setenv("HOME", pwd->pw_dir, 1);
-	if (term != NULL && *term != '\0')
-		(void)setenv("TERM", term, 1);		/* Preset overrides */
-	else {
-		(void)setenv("TERM", stypeof(tty), 0);	/* Fallback doesn't */
-	}
-	(void)setenv("LOGNAME", username, 1);
-	(void)setenv("USER", username, 1);
-	(void)setenv("PATH", rootlogin ? _PATH_STDPATH : _PATH_DEFPATH, 0);
+	if (setenv("SHELL", pwd->pw_shell, 1) == -1) {
+		syslog(LOG_ERR, "setenv: SHELL: %s", strerror(errno));
+		exit(1);
+	}
+	if (setenv("HOME", pwd->pw_dir, 1) == -1) {
+		syslog(LOG_ERR, "setenv: HOME: %s", strerror(errno));
+		exit(1);
+	}
+	if (term != NULL && *term != '\0') {
+		if (setenv("TERM", term, 1) == -1) {		/* Preset overrides */
+			syslog(LOG_ERR, "setenv: TERM: %s", strerror(errno));
+			exit(1);
+		}
+	} else {
+		if (setenv("TERM", stypeof(tty), 0) == -1) {	/* Fallback doesn't */
+			syslog(LOG_ERR, "setenv: TERM: %s", strerror(errno));
+			exit(1);
+		}
+	}
+	if (setenv("LOGNAME", username, 1) == -1) {
+		syslog(LOG_ERR, "setenv: LOGNAME: %s", strerror(errno));
+		exit(1);
+	}
+	if (setenv("USER", username, 1) == -1) {
+		syslog(LOG_ERR, "setenv: USER: %s", strerror(errno));
+		exit(1);
+	}
+	if (setenv("PATH", rootlogin ? _PATH_STDPATH : _PATH_DEFPATH, 0) == -1) {
+		syslog(LOG_ERR, "setenv: PATH: %s", strerror(errno));
+		exit(1);
+	}
 
 	if (!quietlog) {
 		char	*cw;
@@ -857,8 +878,13 @@
 	char	**pp;
 
 	for (pp = environ_pam; *pp != NULL; pp++) {
-		if (ok_to_export(*pp))
-			(void) putenv(*pp);
+		if (ok_to_export(*pp)) {
+			if (putenv(*pp) == -1) {
+				syslog(LOG_ERR, "putenv: %s: %m", *pp);
+				free(*pp);
+				return PAM_SYSTEM_ERR;
+			}
+		}
 		free(*pp);
 	}
 	return PAM_SUCCESS;
Index: usr.bin/make/job.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/make/job.c,v
retrieving revision 1.141
diff -u -r1.141 job.c
--- usr.bin/make/job.c	10 Aug 2005 16:50:36 -0000	1.141
+++ usr.bin/make/job.c	16 Aug 2005 17:37:54 -0000
@@ -408,7 +408,8 @@
 	} else {
 		char new_value[32];
 		sprintf(new_value, "%d", level + 1);
-		setenv(MKLVL_ENVVAR, new_value, 1);
+		if (setenv(MKLVL_ENVVAR, new_value, 1) == -1)
+			Punt("setenv: %s: can't allocate memory", MKLVL_ENVVAR);
 	}
 }
 
@@ -2387,7 +2388,8 @@
 			fifoMaster = 1;
 			fcntl(fifoFd, F_SETFL, O_NONBLOCK);
 			env = fifoName;
-			setenv("MAKE_JOBS_FIFO", env, 1);
+			if (setenv("MAKE_JOBS_FIFO", env, 1) == -1)
+				Punt("setenv: MAKE_JOBS_FIFO: can't allocate memory");
 			while (maxproc-- > 0) {
 				write(fifoFd, "+", 1);
 			}
Index: usr.bin/make/main.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/make/main.c,v
retrieving revision 1.140
diff -u -r1.140 main.c
--- usr.bin/make/main.c	3 Aug 2005 18:34:39 -0000	1.140
+++ usr.bin/make/main.c	16 Aug 2005 17:37:54 -0000
@@ -1004,8 +1004,10 @@
 		const char *p;
 
 		p = Var_Value(".MAKEFLAGS", VAR_GLOBAL);
-		if (p != NULL && *p != '\0')
-			setenv("MAKEFLAGS", p, 1);
+		if (p != NULL && *p != '\0') {
+			if (setenv("MAKEFLAGS", p, 1) == -1)
+				Punt("setenv: MAKEFLAGS: can't allocate memory");
+		}
 	}
 
 	/*
Index: usr.bin/make/var.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/make/var.c,v
retrieving revision 1.217
diff -u -r1.217 var.c
--- usr.bin/make/var.c	5 Aug 2005 22:42:12 -0000	1.217
+++ usr.bin/make/var.c	16 Aug 2005 17:37:54 -0000
@@ -998,7 +998,8 @@
 			 * are automatically exported to the
 			 * environment (as per POSIX standard)
 			 */
-			setenv(n, val, 1);
+			if (setenv(n, val, 1) == -1)
+				Punt( "setenv: %s: can't allocate memory", n);
 		}
 	} else {
 		Buf_Clear(v->val);
@@ -1010,7 +1011,8 @@
 			 * are automatically exported to the
 			 * environment (as per POSIX standard)
 			 */
-			setenv(n, val, 1);
+			if (setenv(n, val, 1) == -1)
+				Punt( "setenv: %s: can't allocate memory", n);
 		}
 
 	}
@@ -1054,12 +1056,14 @@
 	if (v == NULL) {
 		Lst_AtFront(&VAR_ENV->context,
 		    VarCreate(name, NULL, VAR_TO_ENV));
-		setenv(name, "", 1);
+		if (setenv(name, "", 1) == -1)
+			Punt( "setenv: %s: can't allocate memory", name);
 		Error("Warning: .EXPORTVAR: set on undefined variable %s", name);
 	} else {
 		if ((v->flags & VAR_TO_ENV) == 0) {
 			v->flags |= VAR_TO_ENV;
-			setenv(v->name, Buf_Data(v->val), 1);
+			if (setenv(v->name, Buf_Data(v->val), 1) == -1)
+				Punt( "setenv: %s: can't allocate memory", v->name);	
 		}
 	}
 }
Index: usr.bin/objformat/objformat.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/objformat/objformat.c,v
retrieving revision 1.17
diff -u -r1.17 objformat.c
--- usr.bin/objformat/objformat.c	20 Apr 2005 21:39:00 -0000	1.17
+++ usr.bin/objformat/objformat.c	16 Aug 2005 17:37:55 -0000
@@ -169,7 +169,8 @@
 
 	path = strdup(objformat_path);
 
-	setenv("OBJFORMAT", objformat, 1);
+	if (setenv("OBJFORMAT", objformat, 1) == -1)
+		err(1, "setenv: OBJFORMAT");
 
 	/*
 	 * objformat_path could be sequence of colon-separated paths.
Index: usr.bin/su/su.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/su/su.c,v
retrieving revision 1.8
diff -u -r1.8 su.c
--- usr.bin/su/su.c	14 Mar 2005 11:55:33 -0000	1.8
+++ usr.bin/su/su.c	16 Aug 2005 17:37:55 -0000
@@ -396,21 +396,30 @@
 			/* set the su'd user's environment & umask */
 			setusercontext(lc, pwd, pwd->pw_uid, LOGIN_SETPATH|LOGIN_SETUMASK|LOGIN_SETENV);
 #else
-			setenv("PATH", _PATH_DEFPATH, 1);
+			if (setenv("PATH", _PATH_DEFPATH, 1) == -1)
+				err(1, "setenv: PATH");
 #endif
-			if (p)
-				setenv("TERM", p, 1);
+			if (p) {
+				if (setenv("TERM", p, 1) == -1)
+					err(1, "setenv: TERM");
+			}
 #ifdef KERBEROS5
-			if (ccname)
-				setenv("KRB5CCNAME", ccname, 1);
+			if (ccname) {
+				if (setenv("KRB5CCNAME", ccname, 1) == -1)
+					err(1, "setenv: KRB5CCNAME");
+			}
 #endif
 			if (chdir(pwd->pw_dir) < 0)
 				errx(1, "no directory");
 		}
-		if (asthem || pwd->pw_uid)
-			setenv("USER", pwd->pw_name, 1);
-		setenv("HOME", pwd->pw_dir, 1);
-		setenv("SHELL", shell, 1);
+		if (asthem || pwd->pw_uid) {
+			if (setenv("USER", pwd->pw_name, 1) == -1)
+				err(1, "setenv: USER");
+		}
+		if (setenv("HOME", pwd->pw_dir, 1) == -1)
+			err(1, "setenv: HOME");
+		if (setenv("SHELL", shell, 1) == -1)
+			err(1, "setenv: SHELL");
 	}
 	if (iscsh == YES) {
 		if (fastlogin)
Index: usr.bin/tabs/tabs.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/tabs/tabs.c,v
retrieving revision 1.1
diff -u -r1.1 tabs.c
--- usr.bin/tabs/tabs.c	19 Jun 2004 22:03:08 -0000	1.1
+++ usr.bin/tabs/tabs.c	16 Aug 2005 17:37:55 -0000
@@ -108,12 +108,14 @@
 				errx(1, "%s: invalid increment", arg + 1);
 		} else if (arg[1] == 'T') {
 			/* -Ttype or -T type */
-			if (arg[2] != '\0')
-				setenv("TERM", arg + 2, 1);
-			else {
+			if (arg[2] != '\0') {
+				if (setenv("TERM", arg + 2, 1) == -1)
+					err(1, "setenv: TERM");
+			} else {
 				if ((arg = *++argv) == NULL)
 					usage();
-				setenv("TERM", arg, 1);
+				if (setenv("TERM", arg, 1) == -1)
+					err(1, "setenv: TERM");
 			}
 		} else if (arg[1] == '-') {
 			arg = *++argv;
Index: usr.bin/whereis/whereis.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/whereis/whereis.c,v
retrieving revision 1.2
diff -u -r1.2 whereis.c
--- usr.bin/whereis/whereis.c	23 Jul 2004 06:24:27 -0000	1.2
+++ usr.bin/whereis/whereis.c	16 Aug 2005 17:37:55 -0000
@@ -384,7 +384,8 @@
 		errx(EX_DATAERR, "no directories to search");
 
 	if (opt_m) {
-		setenv("MANPATH", colonify(mandirs), 1);
+		if (setenv("MANPATH", colonify(mandirs), 1) == -1)
+			err(1, "setenv: MANPATH");
 		if ((i = regcomp(&re, MANWHEREISMATCH, REG_EXTENDED)) != 0) {
 			regerror(i, &re, buf, BUFSIZ - 1);
 			errx(EX_UNAVAILABLE, "regcomp(%s) failed: %s",
Index: usr.bin/window/wwenviron.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/window/wwenviron.c,v
retrieving revision 1.2
diff -u -r1.2 wwenviron.c
--- usr.bin/window/wwenviron.c	17 Jun 2003 04:29:34 -0000	1.2
+++ usr.bin/window/wwenviron.c	16 Aug 2005 17:37:55 -0000
@@ -92,9 +92,11 @@
 	 */
 	(void) sprintf(buf, "%sco#%d:li#%d:%s",
 		WWT_TERMCAP, wp->ww_w.nc, wp->ww_w.nr, wwwintermcap);
-	(void) setenv("TERMCAP", buf, 1);
+	if (setenv("TERMCAP", buf, 1) == -1)
+		goto bad;
 	(void) sprintf(buf, "%d", wp->ww_id + 1);
-	(void) setenv("WINDOW_ID", buf, 1);
+	if (setenv("WINDOW_ID", buf, 1) == -1)
+		goto bad;
 	return 0;
 bad:
 	wwerrno = WWE_SYS;
Index: usr.bin/window/wwinit.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/window/wwinit.c,v
retrieving revision 1.2
diff -u -r1.2 wwinit.c
--- usr.bin/window/wwinit.c	17 Jun 2003 04:29:34 -0000	1.2
+++ usr.bin/window/wwinit.c	16 Aug 2005 17:37:55 -0000
@@ -303,7 +303,8 @@
 	 * since tt_init() has already made its own copy of it and
 	 * wwterm now points to the copy.
 	 */
-	(void) setenv("TERM", WWT_TERM, 1);
+	if (setenv("TERM", WWT_TERM, 1) == -1)
+		goto bad;
 #ifdef TERMINFO
 	if (wwterminfoinit() < 0)
 		goto bad;
Index: usr.bin/window/wwterminfo.c
===================================================================
RCS file: /home/dcvs/src/usr.bin/window/wwterminfo.c,v
retrieving revision 1.2
diff -u -r1.2 wwterminfo.c
--- usr.bin/window/wwterminfo.c	17 Jun 2003 04:29:34 -0000	1.2
+++ usr.bin/window/wwterminfo.c	16 Aug 2005 17:37:55 -0000
@@ -68,7 +68,10 @@
 		wwerrno = WWE_SYS;
 		return -1;
 	}
-	(void) setenv("TERMINFO", wwterminfopath, 1);
+	if (setenv("TERMINFO", wwterminfopath, 1) == -1) {
+		wwerrno = WWE_SYS;
+		return -1;
+	}
 		/* make a termcap entry and turn it into terminfo */
 	(void) sprintf(buf, "%s/cap", wwterminfopath);
 	if ((fp = fopen(buf, "w")) == NULL) {
Index: usr.sbin/acpi/Makefile.inc
===================================================================
RCS file: /home/dcvs/src/usr.sbin/acpi/Makefile.inc,v
retrieving revision 1.3
diff -u -r1.3 Makefile.inc
--- usr.sbin/acpi/Makefile.inc	16 Aug 2005 10:31:35 -0000	1.3
+++ usr.sbin/acpi/Makefile.inc	16 Aug 2005 17:37:55 -0000
@@ -1,24 +1,16 @@
 # $Id: Makefile.inc,v 1.1 2000/07/14 18:16:22 iwasaki Exp $
 # $FreeBSD: src/usr.sbin/acpi/Makefile.inc,v 1.8 2003/08/07 16:51:50 njl Exp $
-# $DragonFly: src/usr.sbin/acpi/Makefile.inc,v 1.3 2005/08/16 10:31:35 y0netan1 Exp $
+# $DragonFly: src/usr.sbin/acpi/Makefile.inc,v 1.2 2005/03/11 18:27:49 y0netan1 Exp $
 
 SYSDIR?= ${.CURDIR}/../../../sys
-.include "${SYSDIR}/conf/acpi.mk"
+OSACPI_DIR= ${SYSDIR}/dev/acpica5
+.include "${OSACPI_DIR}/Makefile.inc"
 
-.PATH:		${.OBJDIR}				\
-		${SYSDIR}/${ACPICA_DIR}			\
-		${SYSDIR}/${ACPICA_DIR}/compiler	\
-		${SYSDIR}/${ACPICA_DIR}/common
+.PATH:		${SYSACPICA_DIR}		\
+		${SYSACPICA_DIR}/compiler	\
+		${SYSACPICA_DIR}/common
 
-CFLAGS+=	-I${.OBJDIR}				\
-		-I${SYSDIR}/${OSACPI_MI_DIR}		\
-		-I${SYSDIR}/${ACPICA_DIR}/include	\
-		-I${SYSDIR}/${ACPICA_DIR}/compiler
-
-SRCS+=		${.OBJDIR}/acpi.h ${.OBJDIR}/platform/acenv.h
-
-CLEANFILES+=	${.OBJDIR}/acpi.h
-CLEANDIRS+=	${.OBJDIR}/platform
+CFLAGS+=	-I${SYSACPICA_DIR}/compiler
 
 .if exists(${.CURDIR}/../../Makefile.inc)
 .include "${.CURDIR}/../../Makefile.inc"
Index: usr.sbin/cron/cron/cron.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/cron/cron/cron.c,v
retrieving revision 1.6
diff -u -r1.6 cron.c
--- usr.sbin/cron/cron/cron.c	18 Dec 2004 22:48:03 -0000	1.6
+++ usr.sbin/cron/cron/cron.c	16 Aug 2005 17:37:56 -0000
@@ -88,7 +88,10 @@
 	set_cron_cwd();
 
 #if defined(POSIX)
-	setenv("PATH", _PATH_DEFPATH, 1);
+	if (setenv("PATH", _PATH_DEFPATH, 1) == -1) {
+		log_it("CRON",getpid(),"DEATH","setenv: PATH: can't allocate memory");
+		exit(ERROR_EXIT);
+	}
 #endif
 
 	/* if there are no debug flags turned on, fork as a daemon should.
Index: usr.sbin/inetd/inetd.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/inetd/inetd.c,v
retrieving revision 1.8
diff -u -r1.8 inetd.c
--- usr.sbin/inetd/inetd.c	21 Mar 2005 19:26:14 -0000	1.8
+++ usr.sbin/inetd/inetd.c	16 Aug 2005 17:37:57 -0000
@@ -504,7 +504,10 @@
 
 		memset(dummy, 'x', DUMMYSIZE - 1);
 		dummy[DUMMYSIZE - 1] = '\0';
-		setenv("inetd_dummy", dummy, 1);
+		if (setenv("inetd_dummy", dummy, 1) == -1) {
+			syslog(LOG_ERR, "setenv: inetd_dummy: %m");
+			exit(EX_OSERR);
+		}
 	}
 
 	if (pipe(signalpipe) != 0) {
Index: usr.sbin/pkg_install/add/main.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/pkg_install/add/main.c,v
retrieving revision 1.11
diff -u -r1.11 main.c
--- usr.sbin/pkg_install/add/main.c	12 Aug 2005 15:57:22 -0000	1.11
+++ usr.sbin/pkg_install/add/main.c	16 Aug 2005 17:37:57 -0000
@@ -238,9 +238,8 @@
 	    errx(1, "chroot to %s failed", Chroot);
     }
     /* Make sure the sub-execs we invoke get found */
-    setenv("PATH", 
-	   "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin",
-	   1);
+    if (setenv("PATH", "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin", 1) == -1)
+	err(1, "setenv: PATH");
 
     /* Set a reasonable umask */
     umask(022);
Index: usr.sbin/pkg_install/add/perform.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/pkg_install/add/perform.c,v
retrieving revision 1.5
diff -u -r1.5 perform.c
--- usr.sbin/pkg_install/add/perform.c	18 Dec 2004 22:48:04 -0000	1.5
+++ usr.sbin/pkg_install/add/perform.c	16 Aug 2005 17:37:57 -0000
@@ -139,8 +139,10 @@
 		errx(1, "unable to make playpen for %lld bytes", (long long)sb.st_size * 4);
 	    where_to = Home;
 	    /* Since we can call ourselves recursively, keep notes on where we came from */
-	    if (!getenv("_TOP"))
-		setenv("_TOP", Home, 1);
+	    if (!getenv("_TOP")) {
+		if (setenv("_TOP", Home, 1) == -1)
+			err(1, "setenv: TOP");
+	    }
 	    if (unpack(pkg_fullname, extract)) {
 		warnx(
 	"unable to extract table of contents file from '%s' - not a package?",
@@ -231,7 +233,11 @@
 	add_plist_top(&Plist, PLIST_CWD, Prefix);
     }
 
-    setenv(PKG_PREFIX_VNAME, (p = find_plist(&Plist, PLIST_CWD)) ? p->name : ".", 1);
+    if (setenv(PKG_PREFIX_VNAME, (p = find_plist(&Plist, PLIST_CWD)) ? p->name : ".", 1) == -1) {
+	warnx("setenv: PKG_PREFIX_VNAME: can't allocate memory");
+	goto fail;
+    }
+
     /* Protect against old packages with bogus @name and origin fields */
     if (Plist.name == NULL)
 	Plist.name = "anonymous";
Index: usr.sbin/pkg_install/create/perform.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/pkg_install/create/perform.c,v
retrieving revision 1.4
diff -u -r1.4 perform.c
--- usr.sbin/pkg_install/create/perform.c	18 Dec 2004 22:48:04 -0000	1.4
+++ usr.sbin/pkg_install/create/perform.c	16 Aug 2005 17:37:57 -0000
@@ -71,10 +71,12 @@
     }
     if (Zipper == BZIP2) {
 	suf = "tbz";
-	setenv("BZIP2", "--best", 0);
+	if (setenv("BZIP2", "--best", 0) == -1)
+		err(2, "setenv: BZIP2");
     } else if (Zipper == GZIP) {
 	suf = "tgz";
-	setenv("GZIP", "-9", 0);
+	if (setenv("GZIP", "-9", 0) == -1)
+		err(2, "setenv: GZIP");
     } else
 	suf = "tar";
 
Index: usr.sbin/pkg_install/delete/perform.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/pkg_install/delete/perform.c,v
retrieving revision 1.4
diff -u -r1.4 perform.c
--- usr.sbin/pkg_install/delete/perform.c	18 Dec 2004 22:48:04 -0000	1.4
+++ usr.sbin/pkg_install/delete/perform.c	16 Aug 2005 17:37:57 -0000
@@ -218,7 +218,10 @@
 	return 1;
     }
 
-    setenv(PKG_PREFIX_VNAME, p->name, 1);
+    if (setenv(PKG_PREFIX_VNAME, p->name, 1) == -1) {
+	warn("setenv: PKG_PREFIX_VNAME");
+	return 1;
+    }
 
     if (fexists(REQUIRE_FNAME)) {
 	if (Verbose)
Index: usr.sbin/pkg_install/lib/pkgwrap.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/pkg_install/lib/pkgwrap.c,v
retrieving revision 1.2
diff -u -r1.2 pkgwrap.c
--- usr.sbin/pkg_install/lib/pkgwrap.c	30 Jul 2004 04:46:13 -0000	1.2
+++ usr.sbin/pkg_install/lib/pkgwrap.c	16 Aug 2005 17:37:57 -0000
@@ -79,7 +79,8 @@
 	cp++;
     strlcat(buffer, "/", sizeof(buffer));
     strlcat(buffer, cp, sizeof(buffer));
-    setenv("PKG_NOWRAP", "1", 1);
+    if (setenv("PKG_NOWRAP", "1", 1) == -1)
+	err(1, "setenv: PKG_NOWRAP");
     execve(buffer, argv, environ);
 
 nowrap:
Index: usr.sbin/pkg_install/sign/pgp_sign.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/pkg_install/sign/pgp_sign.c,v
retrieving revision 1.4
diff -u -r1.4 pgp_sign.c
--- usr.sbin/pkg_install/sign/pgp_sign.c	18 Dec 2004 22:48:04 -0000	1.4
+++ usr.sbin/pkg_install/sign/pgp_sign.c	16 Aug 2005 17:37:57 -0000
@@ -273,7 +273,10 @@
 			sleep(1);
 			close(fd[1]);
 			sprintf(buf, "%d", fd[0]);
-			setenv("PGPPASSFD", buf, 1);
+			if (setenv("PGPPASSFD", buf, 1) == -1) {
+				perror("pkg_sign");
+				exit(EXIT_FAILURE);
+			}
 			printf("Parent process PGPPASSFD=%d.\n", fd[0]);
 		}
 	}
Index: usr.sbin/pstat/pstat.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/pstat/pstat.c,v
retrieving revision 1.15
diff -u -r1.15 pstat.c
--- usr.sbin/pstat/pstat.c	17 Mar 2005 17:28:44 -0000	1.15
+++ usr.sbin/pstat/pstat.c	16 Aug 2005 17:37:57 -0000
@@ -226,7 +226,8 @@
 			fileflag = 1;
 			break;
 		case 'k':
-			putenv("BLOCKSIZE=1K");
+			if (putenv("BLOCKSIZE=1K") == -1)
+				err(1, "putenv: BLOCKSIZE=1K");
 			break;
 		case 'M':
 			memf = optarg;
Index: usr.sbin/tzsetup/tzsetup.c
===================================================================
RCS file: /home/dcvs/src/usr.sbin/tzsetup/tzsetup.c,v
retrieving revision 1.4
diff -u -r1.4 tzsetup.c
--- usr.sbin/tzsetup/tzsetup.c	19 Feb 2005 01:43:06 -0000	1.4
+++ usr.sbin/tzsetup/tzsetup.c	16 Aug 2005 17:37:58 -0000
@@ -586,7 +586,13 @@
 	time_t t = time(0);
 	int rv;
 	
-	setenv("TZ", filename, 1);
+	if (setenv("TZ", filename, 1) == -1) {
+		asprintf(&msg, "setenv: TZ: %s",
+			strerror(errno));
+		dialog_mesgbox("Error", msg, 8, 72);
+		free(msg);
+		return 0;
+	}
 	tzset();
 	tm = localtime(&t);
 


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