From: Stefan Schantl Date: Wed, 10 May 2023 09:52:03 +0000 (+0200) Subject: backup.cgi: Read and deliver the requested backup in pieces X-Git-Tag: v2.27-core175~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c797789c1f45dc76f4cf933ad3e3d24376c2b76e;p=ipfire-2.x.git backup.cgi: Read and deliver the requested backup in pieces Read-in the requested backup file line by line and directly deliver this as stream to the client. This fixes the problem with very big backups on systems with very limited RAM, which resulted in an OOM kill of the CGI and delivery process. Fixes #13096. Signed-off-by: Stefan Schantl Reviewed-by: Michael Tremer --- diff --git a/html/cgi-bin/backup.cgi b/html/cgi-bin/backup.cgi index 1c01cb286f..3888ccbff9 100644 --- a/html/cgi-bin/backup.cgi +++ b/html/cgi-bin/backup.cgi @@ -366,6 +366,13 @@ sub deliver_file() { # Deliver content open(FILE, "<$file") or die "Unable to open $file: $!"; - print ; + + # Read the file line by line and send it + # to the client. + while () { + print $_; + } + + # Close file handle. close(FILE); }