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

Re: [PATCH] corrected setenv|putenv rc checking (bin)


From: "Simon 'corecode' Schubert" <corecode@xxxxxxxxxxxx>
Date: Fri, 30 Sep 2005 11:38:33 +0200

Alexey Slynko wrote:
Index: ls/ls.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/bin/ls/ls.c,v
retrieving revision 1.14
diff -u -r1.14 ls.c
--- ls/ls.c	18 Sep 2005 18:01:49 -0000	1.14
+++ ls/ls.c	29 Sep 2005 00:48:06 -0000
@@ -221,7 +221,8 @@
 			fts_options |= FTS_COMFOLLOW;
 			break;
 		case 'G':
-			setenv("CLICOLOR", "", 1);
+			if (setenv("CLICOLOR", "", 1) != 0)
+				err(1, "setenv: cannot set CLICOLOR");
 			break;
 		case 'L':
 			fts_options &= ~FTS_PHYSICAL;

I still think this shouldn't abort.


Index: sh/var.c
===================================================================
RCS file: /mnt/share/dragonfly-cvs/src/bin/sh/var.c,v
retrieving revision 1.8
diff -u -r1.8 var.c
--- sh/var.c 19 Apr 2005 05:18:19 -0000 1.8
+++ sh/var.c 29 Sep 2005 01:02:35 -0000
@@ -316,7 +317,8 @@
if (vp == &vmpath || (vp == &vmail && ! mpathset()))
chkmail(1);
if ((vp->flags & VEXPORT) && localevar(s)) {
- putenv(s);
+ if (putenv(s) != 0)
+ err(1, "putenv: cannot set %s", s);
setlocale(LC_ALL, "");
}
INTON;
@@ -332,7 +334,8 @@
INTOFF;
*vpp = vp;
if ((vp->flags & VEXPORT) && localevar(s)) {
- putenv(s);
+ if (putenv(s) != 0)
+ err(1, "putenv: cannot set %s", s);
setlocale(LC_ALL, "");
}
INTON;
@@ -553,7 +556,8 @@
vp->flags |= flag;
if ((vp->flags & VEXPORT) && localevar(vp->text)) {
- putenv(vp->text);
+ if (putenv(vp->text) != 0)
+ err(1, "putenv: cannot set %s", vp->text);
setlocale(LC_ALL, "");
}
goto found;

no! don't collapse my shell if it can't allocate an env var! set $? and output a warning. You don't expect the shell to collapse if it can't exec a binary, right?


$ /bin/ehco foo
/bin/ehco: Command not found.

Login: _

WTF?

--
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   / \



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