com php-src: Fix bug #68089 - do not accept options with embedded \0: ext/curl/interface.c ext/curl/tests/bug68089.phpt
| From: | JulienPauli | Date: | Wed, 15 Oct 2014 09:43:37 +0000 |
| Subject: | com php-src: Fix bug #68089 - do not accept options with embedded \0: ext/curl/interface.c ext/curl/tests/bug68089.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-82332@lists.php.net to get a copy of this message | ||
Commit: cc1fe72bc99ae92d2e14275fd97f34960db24032
Author: Stanislav Malyshev <stas@php.net> Sun, 28 Sep 2014 17:53:49 -0700
Committer: Julien Pauli <jpauli@php.net> Wed, 15 Oct 2014 11:43:37 +0200
Parents: 4af06aca40ac4c592a71a0b1206a50fad994de21
Branches: PHP-5.5.18
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cc1fe72bc99ae92d2e14275fd97f34960db24032
Log:
Fix bug #68089 - do not accept options with embedded \0
Conflicts:
ext/curl/interface.c
Bugs:
https://bugs.php.net/68089
Changed paths:
M ext/curl/interface.c
A ext/curl/tests/bug68089.phpt
Diff:
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 765918c..eab2edf 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 0000000..3bd5889
--- /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