Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Feb 1997 23:50:14 -0800 (PST)
From:      John-Mark Gurney <jmg@nike.efn.org>
To:        Guido van Rooij <guido@gvr.win.tue.nl>
Cc:        audit-bin@FreeBSD.ORG, FreeBSD-hackers@FreeBSD.ORG
Subject:   Re: hmm
Message-ID:  <Pine.BSF.3.95q.970219234633.405v-100000@hydrogen.nike.efn.org>
In-Reply-To: <199702200739.IAA04720@gvr.win.tue.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 20 Feb 1997, Guido van Rooij wrote:

> > > It seems a bit strange to me. Just like the first part of the line
> > > underneath btw:
> > > 	if (*p != '\0' && p[strlen(p) - 1] == '[') {
> > > 	    ^^^^^^^^^^
> > 
> > that makes sure that the strlen(p) > 0... you wouldn't want to access
> > p[-1] would you?? 
> > 
> > hope this helps... ttyl..
> > 
> 
> But p points to argv[0]. According to me that is always non-empty.

but as someone pointed out... with a direct exec it can be otherwise...  I
just wrote a couple programs that proved this...  here's the output:
number args: 3
argv[0} len(0):
argv[1} len(6): parama
argv[2} len(6): paramb

basicly the program I ran did:
char *strings[] = { "", "parama", "paramb", 0};
execv("dump", strings);

and dump was a program that did basicly:
for(i=0;i<argc;i++)
    printf("argv[%d} len(%d): %s\n", i, strlen(argv[i]), argv[i]);

so it is possible...

and thanks for making me do the research... always helpful to learn by
experience this sort of thing... :)  ttyl...

John-Mark

gurney_j@efn.org
http://resnet.uoregon.edu/~gurney_j/
Modem/FAX: (541) 683-6954   (FreeBSD Box)

Live in Peace, destroy Micro$oft, support free software, run FreeBSD (unix)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95q.970219234633.405v-100000>