diff options
author | Stanislav Malyshev <stas@php.net> | 2014-09-28 17:53:49 -0700 |
---|---|---|
committer | Ferenc Kovacs <tyrael@php.net> | 2014-10-15 13:32:02 +0200 |
commit | e194927b26701becc0ead43e31ee623ef4aa4eff (patch) | |
tree | 700a7ff835dce7bf6f6f70f979d4e77b54a1d85e | |
parent | 2d7461f7bf5e4a7a134fdb13bda4ba6143ab13e3 (diff) | |
download | php-git-e194927b26701becc0ead43e31ee623ef4aa4eff.tar.gz |
Fix bug #68089 - do not accept options with embedded \0
Conflicts:
ext/curl/interface.c
-rw-r--r-- | ext/curl/interface.c | 5 | ||||
-rw-r--r-- | ext/curl/tests/bug68089.phpt | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c index f8b04295d7..e3e089175f 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -169,6 +169,11 @@ static int php_curl_option_str(php_curl *ch, long option, const char *str, const { CURLcode error = CURLE_OK; + if (strlen(str) != len) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Curl option contains invalid characters (\\0)"); + return 0; + } + #if LIBCURL_VERSION_NUM >= 0x071100 if (make_copy) { #endif diff --git a/ext/curl/tests/bug68089.phpt b/ext/curl/tests/bug68089.phpt new file mode 100644 index 0000000000..3bd5889709 --- /dev/null +++ b/ext/curl/tests/bug68089.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #68089 (NULL byte injection - cURL lib) +--SKIPIF-- +<?php +include 'skipif.inc'; + +?> +--FILE-- +<?php +$url = "file:///etc/passwd\0http://google.com"; +$ch = curl_init(); +var_dump(curl_setopt($ch, CURLOPT_URL, $url)); +?> +Done +--EXPECTF-- +Warning: curl_setopt(): Curl option contains invalid characters (\0) in %s/bug68089.php on line 4 +bool(false) +Done |