diff options
author | Dmitry Stogov <dmitry@php.net> | 2004-06-22 12:42:17 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2004-06-22 12:42:17 +0000 |
commit | 4ea8f4b9f29c86fbe345e85f1d680f9bc9cb7350 (patch) | |
tree | d96666a9a1f4ab246af3101adec065662020940d /ext/soap/php_http.c | |
parent | c055a54343c7d909975e280a1faa054d9dcfef08 (diff) | |
download | php-git-4ea8f4b9f29c86fbe345e85f1d680f9bc9cb7350.tar.gz |
BUGFIX: Segfault if server's URL has no path. ("http://192.168.8.1:180")
Diffstat (limited to 'ext/soap/php_http.c')
-rw-r--r-- | ext/soap/php_http.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 6cc6d01683..b4f9c2351a 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -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)) { |