Skip to content

Commit e2330cc

Browse files
authored
Fix #216: Use random_int() when generating boundary
1 parent 56c0936 commit e2330cc

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Yii Framework 2 HTTP client extension Change Log
55
------------------------
66

77
- Enh #215: Added possibility to skip charset in header on `UrlEncodedFormatter::format()` (egorrishe)
8-
8+
- Enh #216: Use `random_int()` when generating boundary (samdark)
99

1010
2.0.13 December 23, 2020
1111
------------------------

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
}
1919
],
2020
"require": {
21-
"yiisoft/yii2": "~2.0.13"
21+
"yiisoft/yii2": "~2.0.13",
22+
"paragonie/random_compat": ">=1"
2223
},
2324
"require-dev": {
2425
"cweagans/composer-patches": "^1.7",

src/Request.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Request extends Message
6161
* @var array Stores map (alias => name) of the content parameters
6262
*/
6363
private $_contentMap = [];
64-
/**
64+
/**
6565
* @var float stores the starttime of the current request with microsecond-precession
6666
*/
6767
private $_startTime;
@@ -383,7 +383,8 @@ private function prepareMultiPartContent(array $content)
383383

384384
// generate safe boundary :
385385
do {
386-
$boundary = '---------------------' . md5(mt_rand() . microtime());
386+
387+
$boundary = '---------------------' . md5(random_int(0, PHP_INT_MAX) . microtime());
387388
} while (preg_grep("/{$boundary}/", $contentParts));
388389

389390
// add boundary for each part :

0 commit comments

Comments
 (0)