From d6e50e7f419fe0488603ceafa1d98bf07eddf5b3 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 27 Mar 2021 12:24:54 -0700 Subject: [PATCH] Replace some old hard-coded 1024 byte buffers with the new function --- backup-config/backup.cgi | 3 ++- file/show.cgi | 7 ++++--- sarg/view.cgi | 5 +++-- servers/link.cgi | 3 ++- software/view.cgi | 3 ++- squid/calamaris.cgi | 3 ++- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/backup-config/backup.cgi b/backup-config/backup.cgi index 0af584fac..95dcfbd2f 100755 --- a/backup-config/backup.cgi +++ b/backup-config/backup.cgi @@ -50,7 +50,8 @@ else { print "Content-type: application/x-gzip\n\n"; my $buf; open(TEMP, "<$temp"); - while(read(TEMP, $buf, 1024)) { + my $bs = &get_buffer_size(); + while(read(TEMP, $buf, $bs)) { print $buf; } close(TEMP); diff --git a/file/show.cgi b/file/show.cgi index 0d5691407..e3adb94ad 100755 --- a/file/show.cgi +++ b/file/show.cgi @@ -39,6 +39,7 @@ else { } } } +my $bs = &get_buffer_size(); # Dump the file &switch_acl_uid(); @@ -112,7 +113,7 @@ if ($in{'format'}) { print "Content-type: $type\n\n"; open(FILE, $temp); unlink($temp); - while(read(FILE, $buf, 1000*1024)) { + while(read(FILE, $buf, $bs)) { print $buf; } close(FILE); @@ -137,13 +138,13 @@ else { print "X-Content-Type-Options: nosniff\n"; &print_content_type($type); if ($type =~ /^text\/html/i && !$in{'edit'}) { - while(read(FILE, $buf, 1000*1024)) { + while(read(FILE, $buf, $bs)) { $data .= $buf; } print &filter_javascript($data); } else { - while(read(FILE, $buf, 1000*1024)) { + while(read(FILE, $buf, $bs)) { print $buf; } } diff --git a/sarg/view.cgi b/sarg/view.cgi index 7cfd64844..6fcad9542 100755 --- a/sarg/view.cgi +++ b/sarg/view.cgi @@ -21,9 +21,10 @@ if (-d $full && -r "$full/index.html") { } # Display file contents +my $bs = &get_buffer_size(); if ($full =~ /\.(html|htm)$/i && !$config{'naked'}) { open(FILE, "<$full") || &error($text{'view_eopen'}." : $full"); - while(read(FILE, $buf, 1024)) { + while(read(FILE, $buf, $bs)) { $data .= $buf; } close(FILE); @@ -57,7 +58,7 @@ else { open(FILE, "<$full") || &error($text{'view_eopen'}." : $full"); print "Content-type: ",&guess_mime_type($full, "text/plain"),"\n"; print "\n"; - while(read(FILE, $buf, 1024)) { + while(read(FILE, $buf, $bs)) { print $buf; } close(FILE); diff --git a/servers/link.cgi b/servers/link.cgi index 17dbbf4f7..0953054ca 100755 --- a/servers/link.cgi +++ b/servers/link.cgi @@ -223,7 +223,8 @@ elsif ($header{'content-type'} && } else { # Just pass through - while(my $buf = &read_http_connection($con, 1024)) { + my $bs = &get_buffer_size(); + while(my $buf = &read_http_connection($con, $bs)) { print $buf; } } diff --git a/software/view.cgi b/software/view.cgi index c200c8b90..e474465bf 100755 --- a/software/view.cgi +++ b/software/view.cgi @@ -42,7 +42,8 @@ else { @st = stat($p); print "Content-length: $st[7]\n"; print "Content-type: $type\n\n"; - while(read(FILE, $buf, 1024)) { + my $bs = &get_buffer_size(); + while(read(FILE, $buf, $bs)) { print $buf; } close(FILE); diff --git a/squid/calamaris.cgi b/squid/calamaris.cgi index 7a7f127d8..1dc698c72 100755 --- a/squid/calamaris.cgi +++ b/squid/calamaris.cgi @@ -94,7 +94,8 @@ else { foreach my $f (@files) { open($fh3, "<$f->[0]"); my $buf; - while(read($fh3, $buf, 1024) > 0) { + my $bs = &get_buffer_size(); + while(read($fh3, $buf, $bs) > 0) { print $fh2 $buf; } close($fh3);