]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
utils: Fix CID 1638831 Division or modulo by zero
authorShwetha K Acharya <Shwetha.K.Acharya@ibm.com>
Mon, 5 May 2025 07:47:05 +0000 (13:17 +0530)
committerVolker Lendecke <vl@samba.org>
Fri, 16 May 2025 07:10:57 +0000 (07:10 +0000)
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 <Shwetha.K.Acharya@ibm.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri May 16 07:10:57 UTC 2025 on atb-devel-224

source3/utils/smbget.c

index 67ea259afb8463250aac34ed615d832c580f5614..a9899bafa136680a98470cadc7052df5e88ea9e3 100644 (file)
@@ -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;