Skip to content
Snippets Groups Projects
Commit b379a978 authored by sombra2eternity's avatar sombra2eternity Committed by Federico Dossena
Browse files

Avoid DOS with gigant ckSize values (#60)

Normalize quotes and avoid DOS with gigant ckSize values
parent 44a681fa
No related branches found
No related tags found
No related merge requests found
...@@ -4,21 +4,24 @@ ...@@ -4,21 +4,24 @@
@ini_set('output_buffering', 'Off'); @ini_set('output_buffering', 'Off');
@ini_set('output_handler', ''); @ini_set('output_handler', '');
// Headers // Headers
header( "HTTP/1.1 200 OK" ); header('HTTP/1.1 200 OK');
// Download follows... // Download follows...
header('Content-Description: File Transfer'); header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=random.dat'); header('Content-Disposition: attachment; filename=random.dat');
header('Content-Transfer-Encoding: binary'); header('Content-Transfer-Encoding: binary');
// Never cache me // Never cache me
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header("Cache-Control: post-check=0, pre-check=0", false); header('Cache-Control: post-check=0, pre-check=0', false);
header("Pragma: no-cache"); header('Pragma: no-cache');
// Generate data // Generate data
$data=openssl_random_pseudo_bytes(1048576); $data=openssl_random_pseudo_bytes(1048576);
// Deliver chunks of 1048576 bytes // Deliver chunks of 1048576 bytes
for($i=0;$i<intval($_GET["ckSize"]);$i++){ $chunks=isset($_GET['ckSize']) ?? intval($_GET['ckSize']) : 4;
if(empty($chunks)){$chunks = 4;}
if($chunks>100){$chunks = 100;}
for($i=0;$i<$chunks;$i++){
echo $data; echo $data;
flush(); flush();
} }
?> ?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment