File tree Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ if (!is_website_url(http://github.com/$url)) {
4444
4545``` bash
4646# Attacker.
47- $ curl https://www.example.com/upload_photo.php --data " photo=@/etc/password "
47+ $ curl https://www.example.com/upload_photo.php --data " photo=@/etc/passwd "
4848```
4949
5050``` php
Original file line number Diff line number Diff line change 3030$ limit = 1000 ;
3131for ($ i = 0 ; $ i < $ limit ; $ i ++) {
3232 $ url = $ urls [mt_rand (0 , count ($ urls ) - 1 )];
33- $ instance = $ multi_curl ->addGet ($ url );
33+ $ multi_curl ->addGet ($ url );
3434}
3535
3636$ multi_curl ->start ();
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class MultiCurl
1111 private $ activeCurls = array ();
1212 private $ isStarted = false ;
1313 private $ concurrency = 25 ;
14+ private $ nextCurlId = 0 ;
1415
1516 private $ beforeSendFunction = null ;
1617 private $ successFunction = null ;
@@ -736,6 +737,8 @@ public function __destruct()
736737 */
737738 private function queueHandle ($ curl )
738739 {
740+ // Use sequential ids to allow for ordered post processing.
741+ $ curl ->id = $ this ->nextCurlId ++;
739742 $ this ->curls [$ curl ->id ] = $ curl ;
740743 }
741744
Original file line number Diff line number Diff line change @@ -2420,4 +2420,25 @@ public function testAddCurl()
24202420 $ multi_curl ->addCurl ($ curl );
24212421 $ multi_curl ->start ();
24222422 }
2423+
2424+ public function testSequentialId ()
2425+ {
2426+ $ completed = array ();
2427+
2428+ $ multi_curl = new MultiCurl ();
2429+ $ multi_curl ->complete (function ($ instance ) use (&$ completed ) {
2430+ $ completed [] = $ instance ;
2431+ });
2432+
2433+ for ($ i = 0 ; $ i < 100 ; $ i ++) {
2434+ $ multi_curl ->addPost (Test::TEST_URL , $ i );
2435+ }
2436+
2437+ $ multi_curl ->start ();
2438+
2439+ foreach ($ completed as $ instance ) {
2440+ $ sequential_id = $ instance ->getOpt (CURLOPT_POSTFIELDS );
2441+ $ this ->assertEquals ($ sequential_id , $ instance ->id );
2442+ }
2443+ }
24232444}
You can’t perform that action at this time.
0 commit comments