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($url)) {
44
44
45
45
``` bash
46
46
# 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 "
48
48
```
49
49
50
50
``` php
Original file line number Diff line number Diff line change 30
30
$ limit = 1000 ;
31
31
for ($ i = 0 ; $ i < $ limit ; $ i ++) {
32
32
$ url = $ urls [mt_rand (0 , count ($ urls ) - 1 )];
33
- $ instance = $ multi_curl ->addGet ($ url );
33
+ $ multi_curl ->addGet ($ url );
34
34
}
35
35
36
36
$ multi_curl ->start ();
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ class MultiCurl
11
11
private $ activeCurls = array ();
12
12
private $ isStarted = false ;
13
13
private $ concurrency = 25 ;
14
+ private $ nextCurlId = 0 ;
14
15
15
16
private $ beforeSendFunction = null ;
16
17
private $ successFunction = null ;
@@ -736,6 +737,8 @@ public function __destruct()
736
737
*/
737
738
private function queueHandle ($ curl )
738
739
{
740
+ // Use sequential ids to allow for ordered post processing.
741
+ $ curl ->id = $ this ->nextCurlId ++;
739
742
$ this ->curls [$ curl ->id ] = $ curl ;
740
743
}
741
744
Original file line number Diff line number Diff line change @@ -2420,4 +2420,25 @@ public function testAddCurl()
2420
2420
$ multi_curl ->addCurl ($ curl );
2421
2421
$ multi_curl ->start ();
2422
2422
}
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
+ }
2423
2444
}
You can’t perform that action at this time.
0 commit comments