php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #68089
Patch fix-url-5.4 revision 2014-09-29 01:07 UTC by stas@php.net
Patch fix-options-5.5 revision 2014-09-29 01:01 UTC by stas@php.net
revision 2014-09-29 00:57 UTC by stas@php.net
revision 2014-09-29 00:56 UTC by stas@php.net
Patch fix-5.5 revision 2014-09-29 00:54 UTC by stas@php.net
Patch bug68089.diff revision 2014-09-25 10:40 UTC by johannes@php.net

Patch fix-url-5.4 for *General Issues Bug #68089

Patch version 2014-09-29 01:07 UTC

Return to Bug #68089 | Download this patch
Patch Revisions:

Developer: stas@php.net

commit 9f686d72079acc22a308be7eee101a4a92c16008
Author: Stanislav Malyshev <stas@php.net>
Date:   Sun Sep 28 17:53:49 2014 -0700

    Fix bug #68089 - do not accept options with embedded \0
    
    Conflicts:
    	ext/curl/interface.c

diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 8915625..23b1252 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -170,6 +170,12 @@ static int php_curl_option_url(php_curl *ch, const char *url, const int len TSRM
 #if LIBCURL_VERSION_NUM < 0x071100
 	char *copystr = NULL;
 #endif
+
+	if (strlen(url) != len) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Curl option contains invalid characters (\\0)");
+		return 0;
+	}
+
 	/* Disable file:// if open_basedir are used */
 	if (PG(open_basedir) && *PG(open_basedir)) {
 #if LIBCURL_VERSION_NUM >= 0x071304
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
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 23:01:22 2019 UTC