fix overflow panic during upload

if *only* data chunks are registered (high chance during incremental
backup), then chunk_count might be one lower then upload_stat.count
because of the zero chunk being unconditionally uploaded but not used.
Thus when subtracting the two, an overflow would occur.

In general, don't let the client make the server panic, instead just set
duplicates to 0.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
Stefan Reiter 2020-06-23 14:43:09 +02:00 committed by Dietmar Maurer
parent b91b7d9ffd
commit 8268c9d161

View File

@ -310,7 +310,13 @@ impl BackupEnvironment {
self.log(format!("Upload size: {} ({}%)", upload_stat.size, (upload_stat.size*100)/size));
let client_side_duplicates = chunk_count - upload_stat.count;
// account for zero chunk, which might be uploaded but never used
let client_side_duplicates = if chunk_count < upload_stat.count {
0
} else {
chunk_count - upload_stat.count
};
let server_side_duplicates = upload_stat.duplicates;
if (client_side_duplicates + server_side_duplicates) > 0 {