From f2f8e89f08cdf01c83a0b8ab053c65329d85ca90 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 26 Jul 2017 18:35:42 +0200 Subject: fail early in http if server answer is too small as well Failing on too much data is good, but we can do better by checking for exact filesizes as we know with hashsums how large a file should be, so if we get a file which has a size we do not expect we can drop it directly, regardless of if the file is larger or smaller than what we expect which should catch most cases which would end up as hashsum errors later now a lot sooner. --- methods/http.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'methods/http.cc') diff --git a/methods/http.cc b/methods/http.cc index 9425145dd..db4542981 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -596,7 +596,7 @@ bool HttpServerState::RunData(RequestState &Req) if (Req.MaximumSize != 0 && Req.DownloadSize > Req.MaximumSize) { Owner->SetFailReason("MaximumSizeExceeded"); - return _error->Error(_("File is larger than expected (%llu > %llu). Mirror sync in progress?"), + return _error->Error(_("File has unexpected size (%llu != %llu). Mirror sync in progress?"), Req.DownloadSize, Req.MaximumSize); } In.Limit(Req.DownloadSize); @@ -837,7 +837,7 @@ bool HttpServerState::Go(bool ToFile, RequestState &Req) if (Req.MaximumSize > 0 && Req.File.IsOpen() && Req.File.Failed() == false && Req.File.Tell() > Req.MaximumSize) { Owner->SetFailReason("MaximumSizeExceeded"); - return _error->Error(_("File is larger than expected (%llu > %llu). Mirror sync in progress?"), + return _error->Error(_("File has unexpected size (%llu != %llu). Mirror sync in progress?"), Req.File.Tell(), Req.MaximumSize); } -- cgit v1.2.3