httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Sutton <p...@eu.c2.net>
Subject PATCH NT: spaces in argv[]
Date Sat, 15 Nov 1997 17:11:33 GMT
On Fri, 14 Nov 1997, Paul Sutton wrote:
> On Fri, 14 Nov 1997, Ben Laurie wrote:
> > Hmmm ... well, we can default the path to something without spaces for
> > now (I think that isn't too painful), and hope not too many people
> > change it to something with spaces. The fix isn't that hard, just
> > totally digusting, and haven't had the time to do it (and I'm cooking
> > major Chinese this evening, so I won't have the time today :-).
> 
> I've already sent a patch for this. It results in the lose of memory
> thought at the moment. If Windows is so braindead we really need to code
> around it, we'll need to pass the parent's pool into the function which
> spawns children. 

Ok, here is a slightly better patch. This doesn't waste space. We don't
care about performance since this function is only called to create child
processes, while most work is done by creating threads inside in a single
process. Win32 must have the world's worst implementation of spawn(). 

//pcs

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);
+            *(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;
 



Mime
View raw message