|
|||||||||||
|
Re: Register pointers in gcc?
From: Warner Losh <imp(at)village.org>
Date: Sun Feb 16 1997 - 13:38:48 EST In message <Pine.BSF.3.95.970216130504.25797F-100000@alpha.risc.org> Brian Tao writes:
: I was looking at the disklabel(8) source today and found this in
: editit():
: if ((ed = getenv("EDITOR")) == (char *)0)
: ed = DEFEDITOR;
: How come I can stuff anything into EDITOR and not cause disklabel
: to segfault? I've setenv EDITOR to 16K strings and it just complains
: that the argument list is too long, or that the editor does not exist.
: Where is it storing the contents of getenv("EDITOR")?
getenv is stored in the environment space of the process, so it grows and shrinks dynamically. Since there are no strcpy's here, it works. I'm a little surprised that the kernel doesn't barf on the string being >> MAXPATHLEN, but that's a whole other set of bugs that I don't think have been well looked for, even in OpenBSD: Passing args to the kernel that are too big. I think that this turns into a NDINIT call in the kernel, but haven't traced it past that point yet. BTW, OpenBSD integrated some changes, appended below with change info, to disklabel that are likely desirable. There were some problems with signals that you might want to look into. Warner
revision 1.27
Index: disklabel.c RCS file: /home/imp/OpenBSD/CVS/src/sbin/disklabel/disklabel.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- disklabel.c 1996/12/13 16:58:25 1.26 +++ disklabel.c 1997/02/16 07:42:52 1.27
/*
#ifndef lint
#include <sys/param.h>
int pid, xpid;
int stat;
extern char *getenv();
- sigset_t sigset, osigset;
char *argp[] = {"sh", "-c", NULL, NULL};
char *ed, *p;
} Received on Sun Feb 16 10:38:59 1997 This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 12:41:02 EDT |
||||||||||
|
|||||||||||