diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2005-05-06 02:13:46 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2005-05-06 02:13:46 +0000 |
| commit | a63f5d1c3f9980499a523a2565c855bbdf98f6a9 (patch) | |
| tree | 37fc8379914ec34f82eeb7d074846d1702ad4993 /ext/standard/http_fopen_wrapper.c | |
| parent | d34e9a33a55a691ad60de62bbfed8b9db3be0eba (diff) | |
| download | php-git-a63f5d1c3f9980499a523a2565c855bbdf98f6a9.tar.gz | |
Fixed bug #32936 (http redirects URLs are not checked for control chars).
Diffstat (limited to 'ext/standard/http_fopen_wrapper.c')
| -rw-r--r-- | ext/standard/http_fopen_wrapper.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index db7e5ee54c..066af3cb24 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -551,6 +551,34 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *path, } else { strlcpy(new_path, location, sizeof(new_path)); } + + php_url_free(resource); + /* check for invalid redirection URLs */ + if ((resource = php_url_parse(new_path)) == NULL) { + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect url! %s", new_path); + goto out; + } + +#define CHECK_FOR_CNTRL_CHARS(val) { \ + if (val) { \ + unsigned char *s, *e; \ + int l; \ + l = php_url_decode(val, strlen(val)); \ + s = val; e = s + l; \ + while (s < e) { \ + if (iscntrl(*s)) { \ + php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Invalid redirect url! %s", new_path); \ + goto out; \ + } \ + s++; \ + } \ + } \ +} \ + /* check for control characters in login, password & path */ + CHECK_FOR_CNTRL_CHARS(resource->user) + CHECK_FOR_CNTRL_CHARS(resource->pass) + CHECK_FOR_CNTRL_CHARS(resource->path) + stream = php_stream_url_wrap_http_ex(wrapper, new_path, mode, options, opened_path, context, --redirect_max, 0 STREAMS_CC TSRMLS_CC); if (stream && stream->wrapperdata) { entryp = &entry; |
