From 17724f2b9bd6fea961c4c43da98261cfc4cd0b26 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 26 Mar 2021 13:17:47 -0700 Subject: [PATCH] Move buffer size into a global --- fastrpc.cgi | 4 ++-- web-lib-funcs.pl | 8 ++++---- web-lib.pl | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fastrpc.cgi b/fastrpc.cgi index cf6fd8093..06b217cce 100755 --- a/fastrpc.cgi +++ b/fastrpc.cgi @@ -151,7 +151,7 @@ while(1) { if (open(FILE, ">$file")) { binmode(FILE); print STDERR "fastrpc: tcpwrite $file writing\n" if ($gconfig{'rpcdebug'}); - while(read(TRANS, $buf, 32768) > 0) { + while(read(TRANS, $buf, $default_bufsize) > 0) { local $ok = (print FILE $buf); if (!$ok) { $err = "Write to $file failed : $!"; @@ -180,7 +180,7 @@ while(1) { local ($data, $got); open(FILE, "<$arg->{'file'}"); binmode(FILE); - while(read(FILE, $got, 32768) > 0) { + while(read(FILE, $got, $default_bufsize) > 0) { $data .= $got; } close(FILE); diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 3b25d7370..a13e003f9 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -28,7 +28,7 @@ use vars qw($module_index_name $number_to_month_map $month_to_number_map $umask_already $default_charset $licence_status $os_type $licence_message $script_name $loaded_theme_oo_library $done_web_lib_funcs $os_version $module_index_link - $called_from_webmin_core $ipv6_module_error); + $called_from_webmin_core $ipv6_module_error $default_bufsize); =head2 read_file(file, &hash, [&order], [lowercase], [split-char]) @@ -635,7 +635,7 @@ my ($in, $out) = @_; $in = &callers_package($in); $out = &callers_package($out); my $buf; -while(read($in, $buf, 32768) > 0) { +while(read($in, $buf, $default_bufsize) > 0) { (print $out $buf) || return 0; } return 1; @@ -7125,7 +7125,7 @@ return &$main::remote_error_handler("Failed to transfer file : $error") if ($error); open(FILE, "<".$localfile) || return &$main::remote_error_handler("Failed to open $localfile : $!"); -while(read(FILE, $got, 32768) > 0) { +while(read(FILE, $got, $default_bufsize) > 0) { print TWRITE $got; } close(FILE); @@ -7163,7 +7163,7 @@ return &$main::remote_error_handler("Failed to transfer file : $error") my $got; open(FILE, ">$localfile") || return &$main::remote_error_handler("Failed to open $localfile : $!"); -while(read(TREAD, $got, 32768) > 0) { +while(read(TREAD, $got, $default_bufsize) > 0) { print FILE $got; } close(FILE); diff --git a/web-lib.pl b/web-lib.pl index 3171f7c28..a7d44bf2f 100755 --- a/web-lib.pl +++ b/web-lib.pl @@ -9,6 +9,7 @@ $main::default_debug_log_size = 10*1024*1024; $webmin_feedback_address = "feedback\@webmin.com"; $default_lang = "en"; $default_charset = "UTF-8"; +$default_bufsize = 32768; =head2 unique(string, ...)