File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed
Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -245,8 +245,8 @@ remove_scheme()
245245 auto begin = s_ + impl_.offset (id_path);
246246 auto it = begin;
247247 auto end = begin + pn;
248- while (* it != ' / ' &&
249- it != end )
248+ while (it != end &&
249+ * it != ' / ' )
250250 ++it;
251251 // we don't need op here because this is
252252 // an internal operation
@@ -2089,8 +2089,8 @@ normalize_path()
20892089 auto end = begin + pn;
20902090 while (core::string_view (it, 2 ) == " ./" )
20912091 it += 2 ;
2092- while (* it != ' / ' &&
2093- it != end )
2092+ while (it != end &&
2093+ * it != ' / ' )
20942094 ++it;
20952095 // we don't need op here because this is
20962096 // an internal operation
@@ -2614,8 +2614,10 @@ first_segment() const noexcept
26142614 p0, end - p0);
26152615 auto p = p0;
26162616 while (*p != ' /' )
2617+ {
2618+ BOOST_ASSERT (p < end);
26172619 ++p;
2618- BOOST_ASSERT (p < end);
2620+ }
26192621 return core::string_view (p0, p - p0);
26202622}
26212623
Original file line number Diff line number Diff line change @@ -1860,6 +1860,23 @@ struct url_base_test
18601860 assert ( url ( " http://www.example.com#%61bc" ).normalize_fragment ().buffer () == " http://www.example.com#abc" );
18611861 }
18621862
1863+ void
1864+ testSetEncodedPathBoundary ()
1865+ {
1866+ // exercise paths that end exactly at
1867+ // iterator boundary (OOB read regression)
1868+ {
1869+ url u;
1870+ u.set_encoded_path (" x" );
1871+ BOOST_TEST_EQ (u.encoded_path (), " x" );
1872+ }
1873+ {
1874+ url u;
1875+ u.set_encoded_path (" " );
1876+ BOOST_TEST (u.encoded_path ().empty ());
1877+ }
1878+ }
1879+
18631880 void
18641881 run ()
18651882 {
@@ -1871,6 +1888,7 @@ struct url_base_test
18711888 testSetHost ();
18721889 testSetPort ();
18731890 testQuery ();
1891+ testSetEncodedPathBoundary ();
18741892 testJavadocs ();
18751893 }
18761894};
You can’t perform that action at this time.
0 commit comments