httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk-Willem van Gulik <di...@elect6.jrc.it>
Subject Re: PATCH NT: spaces in argv[]
Date Mon, 17 Nov 1997 08:50:15 GMT
On Sat, 15 Nov 1997, Ben Laurie wrote:

+1 (tested. though I've done a strcat())

spewed spawn, so sad, sad, sad.

Dw.


> > Index: http_main.c
> > ===================================================================
> > RCS file: /export/home/cvs/apachen/src/main/http_main.c,v
> > retrieving revision 1.250
> > diff -u -r1.250 http_main.c
> > --- http_main.c 1997/11/13 20:20:46     1.250
> > +++ http_main.c 1997/11/15 17:07:17
> > @@ -4183,7 +4183,19 @@
> >      pass_argv[1] = "-c";
> >      pass_argv[2] = buf;
> >      for (i = 1; i < argc; i++) {
> > -       pass_argv[i + 2] = argv[i];
> > +        if (strchr(argv[i], ' ')) {
> > +            /* Incredibly, passing an argument containing spaces within
> > +             * argv[] does not work. We have to manually quote the argument
> > +             * here. Ugh.
> > +             */
> > +            pass_argv[i+2] = alloca(strlen(argv[i])+2+1);

strcat(pass_argv[i+2],"""",argv[i],"""");?

> > +            *(pass_argv[i+2]) = '\"';
> > +            strcpy(pass_argv[i+2]+1, argv[i]);
> > +            strcat(pass_argv[i+2], "\"");
> > +        }
> > +        else {
> > +           pass_argv[i + 2] = argv[i];
> > +        }
> >      }
> >      pass_argv[argc + 2] = NULL;
> > 
> 
> Cool. +1 (untested).
> 
> Cheers,
> 
> Ben.
> 
> -- 
> Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
> Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
> and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
> A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
> London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache
> 


Mime
View raw message