]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
fix uninitialized buf1 in get_checksum2() MD4 path
authorAndrew Tridgell <andrew@tridgell.net>
Tue, 30 Dec 2025 05:21:41 +0000 (16:21 +1100)
committerAndrew Tridgell <andrew@tridgell.net>
Tue, 30 Dec 2025 05:51:43 +0000 (16:51 +1100)
The static buf1 pointer was only allocated when len > len1, but on
first call with len == 0, this condition is false (0 > 0), leaving
buf1 NULL when passed to memcpy().

Fixes #673

checksum.c

index 66e8089678d2e647351f2eb6b4297c41a09b8889..6f0f95abbcf99e4d90c1334ab162f7a1f497d794 100644 (file)
@@ -366,9 +366,8 @@ void get_checksum2(char *buf, int32 len, char *sum)
 
                mdfour_begin(&m);
 
-               if (len > len1) {
-                       if (buf1)
-                               free(buf1);
+               if (len > len1 || !buf1) {
+                       free(buf1);
                        buf1 = new_array(char, len+4);
                        len1 = len;
                }