httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apache-1.3/src/main util_script.c
Date Wed, 09 May 2001 05:17:11 GMT
wrowe       01/05/08 22:17:11

  Modified:    src      CHANGES
               src/main util_script.c
  Log:
    Resolve the win32 exec cmd bug, at least as far as some unixes support
    it.  Presume the command contains a filepath and transpose forward
    slashes to backslashes in the path.  (Note part of the bug, correctly
    identified by the poster of 7415, was the /c flag being transposed to \c).
  
    There has to be a better way, but at least this is now partially, and not
    entirely broken.  Command.com _does_ accept quoted file paths with spaces
    for the executable.
  
  PR:		7415
  
  Revision  Changes    Path
  1.1678    +3 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1677
  retrieving revision 1.1678
  diff -u -r1.1677 -r1.1678
  --- CHANGES	2001/05/06 22:00:01	1.1677
  +++ CHANGES	2001/05/09 05:17:10	1.1678
  @@ -1,5 +1,8 @@
   Changes with Apache 1.3.20
   
  +  *) Resolve the Win32 SSI exec cmd bug, where cmd was not executed
  +     appropriately against the shell.  [William Rowe]
  +
     *) Added NOESCAPE (NS) flag to RewriteRule and enabled use of
        '\' to allow escaping of special characters.  Previously
        there was no way to embed either '$' or '%' in the output
  
  
  
  1.158     +12 -25    apache-1.3/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/util_script.c,v
  retrieving revision 1.157
  retrieving revision 1.158
  diff -u -r1.157 -r1.158
  --- util_script.c	2001/01/15 17:05:07	1.157
  +++ util_script.c	2001/05/09 05:17:11	1.158
  @@ -1102,34 +1102,21 @@
           else /* shellcmd */
           {
               char *p, *comspec = getenv("COMSPEC");
  +            const char *quotecomspec;
  +            const char *quoteargv0;
               if (!comspec)
                   comspec = SHELL_PATH;
               p = strchr(comspec, '\0');
  -            if ((p - comspec >= 11) && !strcasecmp(p - 11, "command.com")) 
  -            {
  -                /* Command.com doesn't like long paths
  -                 */
  -                char shortname[MAX_PATH];
  -                DWORD rv = GetShortPathName(r->filename, shortname, MAX_PATH);
  -                if (!rv || rv >= MAX_PATH) {
  -                    ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r,
  -                                  "%s is not executable; cannot translate "
  -                                  "to a short path name.", r->filename);
  -                    return (pid);
  -                }
  -                pCommand = ap_pstrcat(r->pool, "\"", comspec, "\" /C ", 
  -                                      shortname, NULL);
  -            }
  -            else
  -            {
  -                /* Assume any other shell likes long paths
  -                 */
  -                pCommand = ap_pstrcat(r->pool, "\"", comspec, "\" /C \"", 
  -                                      r->filename, "\"", NULL);
  -                for (p = pCommand; *p; ++p) {
  -                    if (*p == '/')
  -                        *p = '\\';
  -                }
  +            quotecomspec = (strchr(comspec, ' ') && comspec[0] != '\"')
  +                         ? "\"" : "";
  +            quoteargv0 = (strchr(argv0, ' ') && argv0[0] != '\"') ? "\"" : "";
  +            pCommand = ap_pstrcat(r->pool, quotecomspec, comspec, quotecomspec,
  +                                  " /c ", quoteargv0, argv0, quoteargv0, NULL);
  +            /* Forward slash argv[0] only */
  +            for (p = pCommand + strlen(pCommand) - strlen(argv0) 
  +                              - strlen(quoteargv0); *p; ++p) {
  +                if (*p == '/')
  +                    *p = '\\';
               }
           }
   
  
  
  

Mime
View raw message