]> granicus.if.org Git - php/commitdiff
MFH: Fix a bug when command is quoted and parameters are quoted during call to exec...
authorScott MacVicar <scottmac@php.net>
Thu, 29 May 2008 11:41:50 +0000 (11:41 +0000)
committerScott MacVicar <scottmac@php.net>
Thu, 29 May 2008 11:41:50 +0000 (11:41 +0000)
NEWS
TSRM/tsrm_win32.c

diff --git a/NEWS b/NEWS
index 28f95a3a3d51036e3931dbdd3d7aeee228bb4520..5e45a65f94efde5f591637a9fbf5269e44428292 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ PHP                                                                        NEWS
 - Fixed a crash inside PDO when trying instantiate PDORow manually (Felipe)
 - Fixed build failure of ext/mysqli with libmysql 6.0 - missing rpl
   functions. (Andrey)
+- Fixed a bug where exec() on Windows would eat the first and last double quotes
+  (Scott)
 - Fixed bug #45004 (pg_insert() does not accept 4 digit timezone format).
   (Ilia)
 - Fixed bug #44891 Memory leak using registerPHPFunctions and XSLT Variable 
index 2c9a24f35f09fb7cd3f149f3b8048f2584e5b687..57f9fbc9fd0a8da6109f8c08509f3b39f3f7f534 100644 (file)
@@ -88,7 +88,7 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
 {
        if (mode == 1 /*X_OK*/) {
 #if 1
-               /* This code is not supported by Windows 98, 
+               /* This code is not supported by Windows 98,
                 * but we don't support it anymore */
                DWORD type;
 
@@ -96,7 +96,7 @@ TSRM_API int tsrm_win32_access(const char *pathname, int mode)
 #else
                SHFILEINFO sfi;
 
-               return access(pathname, 0) == 0 && 
+               return access(pathname, 0) == 0 &&
                        SHGetFileInfo(pathname, 0, &sfi, sizeof(SHFILEINFO), SHGFI_EXETYPE) != 0 ? 0 : -1;
 #endif
        } else {
@@ -109,22 +109,22 @@ static process_pair *process_get(FILE *stream TSRMLS_DC)
 {
        process_pair *ptr;
        process_pair *newptr;
-       
+
        for (ptr = TWG(process); ptr < (TWG(process) + TWG(process_size)); ptr++) {
                if (ptr->stream == stream) {
                        break;
                }
        }
-       
+
        if (ptr < (TWG(process) + TWG(process_size))) {
                return ptr;
        }
-       
+
        newptr = (process_pair*)realloc((void*)TWG(process), (TWG(process_size)+1)*sizeof(process_pair));
        if (newptr == NULL) {
                return NULL;
        }
-       
+
        TWG(process) = newptr;
        ptr = newptr + TWG(process_size);
        TWG(process_size)++;
@@ -136,7 +136,7 @@ static shm_pair *shm_get(int key, void *addr)
        shm_pair *ptr;
        shm_pair *newptr;
        TSRMLS_FETCH();
-       
+
        for (ptr = TWG(shm); ptr < (TWG(shm) + TWG(shm_size)); ptr++) {
                if (!ptr->descriptor) {
                        continue;
@@ -151,12 +151,12 @@ static shm_pair *shm_get(int key, void *addr)
        if (ptr < (TWG(shm) + TWG(shm_size))) {
                return ptr;
        }
-       
+
        newptr = (shm_pair*)realloc((void*)TWG(shm), (TWG(shm_size)+1)*sizeof(shm_pair));
        if (newptr == NULL) {
                return NULL;
        }
-       
+
        TWG(shm) = newptr;
        ptr = newptr + TWG(shm_size);
        TWG(shm_size)++;
@@ -195,7 +195,7 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
        if (!str_len || !CreatePipe(&in, &out, &security, 2048L)) {
                return NULL;
        }
-       
+
        memset(&startup, 0, sizeof(STARTUPINFO));
        memset(&process, 0, sizeof(PROCESS_INFORMATION));
 
@@ -217,8 +217,8 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
                startup.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
        }
 
-       cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c "));
-       sprintf(cmd, "%s /c %s", TWG(comspec), command);
+       cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c ")+2);
+       sprintf(cmd, "%s /c \"%s\"", TWG(comspec), command);
        if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW, env, cwd, &startup, &process)) {
                return NULL;
        }