Avoid infinite loop if the file's length is negative.
authorWayne Davison <wayned@samba.org>
Sat, 21 Aug 2010 18:26:21 +0000 (11:26 -0700)
committerWayne Davison <wayned@samba.org>
Mon, 6 Sep 2010 15:05:26 +0000 (08:05 -0700)
Fixes bug 4664.

generator.c

index 3467cfa865c6360cbc294cbdc8faa6800ce0eb4a..635fcb9704b77751c9c1eb87f344e674eb6326b1 100644 (file)
@@ -761,6 +761,12 @@ static void sum_sizes_sqroot(struct sum_struct *sum, int64 len)
        int s2length;
        int64 l;
 
+       if (len < 0) {
+               /* The file length overflowed our int64 var, so we can't process this file. */
+               sum->count = -1; /* indicate overflow error */
+               return;
+       }
+
        if (block_size)
                blength = block_size;
        else if (len <= BLOCK_SIZE * BLOCK_SIZE)