Skip to content

Commit eb21540

Browse files
Dmitry TarasovDmitry Tarasov
authored andcommitted
Add argument length limit for ExecTransport
1 parent 0932744 commit eb21540

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/Stackify/Log/Transport/ExecTransport.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class ExecTransport extends AbstractApiTransport
1414

1515
protected $curlPath = 'curl';
1616

17+
const MAX_POST_LENGTH = 65536; // 1024 * 64
18+
const ERROR_LENGTH = 'Batch is too long: %s';
1719
const ERROR_CURL = 'Command returned an error. [Command: "%s"] [Return code: %d] [Message: "%s"]';
1820
const SUCCESS_CURL = 'Command sent. [Command: "%s"]';
1921

@@ -59,6 +61,11 @@ protected function send($data)
5961
// return immediately while curl will run in the background
6062
$cmd .= ' > /dev/null 2>&1 &';
6163
}
64+
$cmdLength = strlen($cmd);
65+
if ($cmdLength > self::MAX_POST_LENGTH) {
66+
$this->logError(self::ERROR_LENGTH, $cmdLength);
67+
return;
68+
}
6269
$output = array();
6370
$r = exec($cmd, $output, $result);
6471
// if debug mode is off, it makes no sense to check result,

0 commit comments

Comments
 (0)