From: Shwetha K Acharya Date: Mon, 5 May 2025 07:47:05 +0000 (+0530) Subject: utils: Fix CID 1638831 Division or modulo by zero X-Git-Tag: tevent-0.17.0~173 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=68c7c19a0fb3f7c9124d77674fee5affb8a8ab02;p=thirdparty%2Fsamba.git utils: Fix CID 1638831 Division or modulo by zero The conditions now == start or pos == start_pos are checked at the beginning of the function definition to ensure that avg is non zero. Also an appropriate print statement is added to indicate the print status. Signed-off-by: Shwetha K Acharya Reviewed-by: Anoop C S Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Fri May 16 07:10:57 UTC 2025 on atb-devel-224 --- diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c index 67ea259afb8..a9899bafa13 100644 --- a/source3/utils/smbget.c +++ b/source3/utils/smbget.c @@ -315,9 +315,12 @@ static void print_progress(const char *name, time_t start, time_t now, char hpos[22], htotal[22], havg[22]; char *status, *filename; int len; - if (now - start) { - avg = 1.0 * (pos - start_pos) / (now - start); + + if (now == start || pos == start_pos) { + fprintf(stderr, "\r[%s] No progress yet", name); + return; } + avg = 1.0 * (pos - start_pos) / (now - start); eta = (total - pos) / avg; if (total) { prcnt = 100.0 * pos / total;