diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2003-02-19 00:49:31 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2003-02-19 00:49:31 +0000 |
commit | a6ef609a371e6dfeb4ca89c576f8c4037e4bf754 (patch) | |
tree | bfdea133c6761bc59b5c133fb3024c15c08e1835 | |
parent | 69113a309992243a3aea68bf8f38dcf4eac55cc0 (diff) | |
download | php-git-a6ef609a371e6dfeb4ca89c576f8c4037e4bf754.tar.gz |
Fixed bug #22283 (possible crash when opening relative URLs).
-rw-r--r-- | ext/standard/http_fopen_wrapper.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 6ce5c96d43..e6da657882 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -348,8 +348,13 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch *new_path='\0'; if (strlen(location)<8 || (strncasecmp(location, "http://", sizeof("http://")-1) && strncasecmp(location, "https://", sizeof("https://")-1))) { if (*location != '/') { - if (*(location+1) != '\0') { - php_dirname(resource->path, strlen(resource->path)); + if (*(location+1) != '\0' && resource->path) { + char *s = strrchr(resource->path, '/'); + if (!s) { + s = resource->path; + *s = '/'; + } + s[1] = '\0'; if (resource->path && *(resource->path) == '/' && *(resource->path + 1) == '\0') { snprintf(loc_path, sizeof(loc_path) - 1, "%s%s", resource->path, location); } else { |