]> granicus.if.org Git - php/commitdiff
Fix bug #68089 - do not accept options with embedded \0
authorStanislav Malyshev <stas@php.net>
Mon, 29 Sep 2014 00:53:49 +0000 (17:53 -0700)
committerStanislav Malyshev <stas@php.net>
Tue, 14 Oct 2014 17:43:59 +0000 (10:43 -0700)
Conflicts:
ext/curl/interface.c

ext/curl/interface.c
ext/curl/tests/bug68089.phpt [new file with mode: 0644]

index 765918cc3546ce1a1ed9c8697b234e01e3028834..eab2edf663b223214f9b626c986be9e9cce64442 100644 (file)
@@ -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 (file)
index 0000000..3bd5889
--- /dev/null
@@ -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