]> granicus.if.org Git - php/commitdiff
BUGFIX: Segfault if server's URL has no path. ("http://192.168.8.1:180")
authorDmitry Stogov <dmitry@php.net>
Tue, 22 Jun 2004 12:42:17 +0000 (12:42 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 22 Jun 2004 12:42:17 +0000 (12:42 +0000)
ext/soap/php_http.c

index 6cc6d016838300059740ad96d41ee1a354b074e8..b4f9c2351a56c6536c079f09f6e43cea5a6e7736 100644 (file)
@@ -372,7 +372,9 @@ try_again:
                        smart_str_appendc(&soap_headers, ':');
                        smart_str_append_unsigned(&soap_headers, phpurl->port);
                }
-               smart_str_appends(&soap_headers, phpurl->path);
+               if (phpurl->path) {
+                       smart_str_appends(&soap_headers, phpurl->path);
+               }
                if (phpurl->query) {
                        smart_str_appendc(&soap_headers, '?');
                        smart_str_appends(&soap_headers, phpurl->query);
@@ -452,7 +454,7 @@ try_again:
                                                    Z_TYPE_PP(value) == IS_STRING) {
                                                  zval **tmp;
                                                  if (zend_hash_index_find(Z_ARRVAL_PP(data), 1, (void**)&tmp) == SUCCESS &&
-                                                     strncmp(phpurl->path,Z_STRVAL_PP(tmp),Z_STRLEN_PP(tmp)) == 0 &&
+                                                     strncmp(phpurl->path?phpurl->path:"/",Z_STRVAL_PP(tmp),Z_STRLEN_PP(tmp)) == 0 &&
                                                      zend_hash_index_find(Z_ARRVAL_PP(data), 2, (void**)&tmp) == SUCCESS &&
                                                      in_domain(phpurl->host,Z_STRVAL_PP(tmp)) &&
                                                      (use_ssl || zend_hash_index_find(Z_ARRVAL_PP(data), 3, (void**)&tmp) == FAILURE)) {
@@ -543,12 +545,13 @@ try_again:
                                          new_url->scheme = estrdup(phpurl->scheme);
                                          new_url->host = estrdup(phpurl->host);
                                          new_url->port = phpurl->port;
-                                               if (new_url->path[0] != '/') {
-                                                 char *p = strrchr(phpurl->path, '/');
-                                                 char *s = emalloc((p - phpurl->path) + strlen(new_url->path) + 2);
+                                               if (new_url->path && new_url->path[0] != '/') {
+                                                 char *t = phpurl->path?phpurl->path:"/";
+                                                 char *p = strrchr(t, '/');
+                                                 char *s = emalloc((p - t) + strlen(new_url->path) + 2);
 
-                                                 strncpy(s, phpurl->path, (p - phpurl->path) + 1);
-                                                 s[(p - phpurl->path) + 1] = 0;
+                                                 strncpy(s, t, (p - t) + 1);
+                                                 s[(p - t) + 1] = 0;
                                                  strcat(s, new_url->path);
                                                  efree(new_url->path);
                                                  new_url->path = s;
@@ -661,9 +664,10 @@ try_again:
                                }
                        }
                        if (!zend_hash_index_exists(Z_ARRVAL_P(zcookie), 1)) {
-                               char *c = strrchr(phpurl->path, '/');
+                               char *t = phpurl->path?phpurl->path:"/";
+                               char *c = strrchr(t, '/');
                                if (c) {
-                                       add_index_stringl(zcookie, 1, phpurl->path, c-phpurl->path, 1);
+                                       add_index_stringl(zcookie, 1, t, c-t, 1);
                                }
                        }
                        if (!zend_hash_index_exists(Z_ARRVAL_P(zcookie), 2)) {