Skip to content

Commit 54dbd3e

Browse files
committed
Fix binary-safety of parse_url
php_parse_url() is intended to support strings that are not zero terminated. We can't use strcspn in the implementation. As we have two uses of strcspn, add a helper.
1 parent 2e9e706 commit 54dbd3e

12 files changed

+33
-13
lines changed

ext/standard/tests/url/parse_url_basic_001.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,11 @@ echo "Done";
854854
string(19) "filter={"id":"123"}"
855855
}
856856

857+
--> %:x: array(1) {
858+
["path"]=>
859+
string(3) "%:x"
860+
}
861+
857862
--> http:///blah.com: bool(false)
858863

859864
--> http://:80: bool(false)

ext/standard/tests/url/parse_url_basic_002.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ echo "Done";
112112
--> : NULL
113113
--> / : NULL
114114
--> /rest/Users?filter={"id":"123"} : NULL
115+
--> %:x : NULL
115116
--> http:///blah.com : bool(false)
116117
--> http://:80 : bool(false)
117118
--> http://user@:80 : bool(false)

ext/standard/tests/url/parse_url_basic_003.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ echo "Done";
111111
--> : NULL
112112
--> / : NULL
113113
--> /rest/Users?filter={"id":"123"} : NULL
114+
--> %:x : NULL
114115
--> http:///blah.com : bool(false)
115116
--> http://:80 : bool(false)
116117
--> http://user@:80 : bool(false)

ext/standard/tests/url/parse_url_basic_004.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ echo "Done";
111111
--> : NULL
112112
--> / : NULL
113113
--> /rest/Users?filter={"id":"123"} : NULL
114+
--> %:x : NULL
114115
--> http:///blah.com : bool(false)
115116
--> http://:80 : bool(false)
116117
--> http://user@:80 : bool(false)

ext/standard/tests/url/parse_url_basic_005.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ echo "Done";
111111
--> : NULL
112112
--> / : NULL
113113
--> /rest/Users?filter={"id":"123"} : NULL
114+
--> %:x : NULL
114115
--> http:///blah.com : bool(false)
115116
--> http://:80 : bool(false)
116117
--> http://user@:80 : bool(false)

ext/standard/tests/url/parse_url_basic_006.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ echo "Done";
111111
--> : NULL
112112
--> / : NULL
113113
--> /rest/Users?filter={"id":"123"} : NULL
114+
--> %:x : NULL
114115
--> http:///blah.com : bool(false)
115116
--> http://:80 : bool(false)
116117
--> http://user@:80 : bool(false)

ext/standard/tests/url/parse_url_basic_007.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ echo "Done";
111111
--> : string(0) ""
112112
--> / : string(1) "/"
113113
--> /rest/Users?filter={"id":"123"} : string(11) "/rest/Users"
114+
--> %:x : string(3) "%:x"
114115
--> http:///blah.com : bool(false)
115116
--> http://:80 : bool(false)
116117
--> http://user@:80 : bool(false)

ext/standard/tests/url/parse_url_basic_008.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ echo "Done";
111111
--> : NULL
112112
--> / : NULL
113113
--> /rest/Users?filter={"id":"123"} : string(19) "filter={"id":"123"}"
114+
--> %:x : NULL
114115
--> http:///blah.com : bool(false)
115116
--> http://:80 : bool(false)
116117
--> http://user@:80 : bool(false)

ext/standard/tests/url/parse_url_basic_009.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ echo "Done";
111111
--> : NULL
112112
--> / : NULL
113113
--> /rest/Users?filter={"id":"123"} : NULL
114+
--> %:x : NULL
114115
--> http:///blah.com : bool(false)
115116
--> http://:80 : bool(false)
116117
--> http://user@:80 : bool(false)

ext/standard/tests/url/parse_url_unterminated.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,11 @@ echo "Done";
856856
string(19) "filter={"id":"123"}"
857857
}
858858

859+
--> %:x: array(1) {
860+
["path"]=>
861+
string(3) "%:x"
862+
}
863+
859864
--> http:///blah.com: bool(false)
860865

861866
--> http://:80: bool(false)

0 commit comments

Comments
 (0)