From cc67335f13b62c177ab2c511a95d2bf31a986170 Mon Sep 17 00:00:00 2001 From: tiptorrent development team Date: Sat, 12 Feb 2022 12:40:33 +0100 Subject: validate received bytes and expected file size --- src/main.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index b48fc78..1372437 100644 --- a/src/main.c +++ b/src/main.c @@ -616,6 +616,12 @@ err: gettimeofday(&tv_stop, NULL); timersub(&tv_stop, &tv_start, &tv); + if (data_len != file_size) { + syslog(LOG_ERR, "Failure, file size is %lu bytes but received %lu bytes!\n", + file_size, data_len); + return EXIT_FAILURE; + } + if (_cli.state == TIP_CLIENT_DONE) { printf("OK.\n"); syslog(LOG_INFO, "Done in %lu.%06lu seconds (%lu Mbytes/second). " -- cgit v1.2.3-18-g5258