diff options
author | Wayne Davison <wayne@opencoder.net> | 2023-04-22 08:49:48 -0700 |
---|---|---|
committer | Wayne Davison <wayne@opencoder.net> | 2023-04-22 08:49:50 -0700 |
commit | 0f599d3641bd197ff01f5182fad33169aa46a055 (patch) | |
tree | 07a3aa2a00a27242267f37d0c2cfd5506a0a33b0 | |
parent | c3d3b49d722439f18be24a0414aa49b4b035841f (diff) | |
download | rsync-0f599d3641bd197ff01f5182fad33169aa46a055.tar.gz |
Fix overflow of sum2 buffer for sha1 rolling checksums.
Fixed #353.
-rw-r--r-- | checksum.c | 1 | ||||
-rw-r--r-- | generator.c | 2 | ||||
-rw-r--r-- | match.c | 2 |
3 files changed, 3 insertions, 2 deletions
@@ -300,6 +300,7 @@ uint32 get_checksum1(char *buf1, int32 len) } #endif +/* The "sum" buffer must be at least MAX_DIGEST_LEN bytes! */ void get_checksum2(char *buf, int32 len, char *sum) { #ifdef USE_OPENSSL diff --git a/generator.c b/generator.c index 21c4a595..557769e6 100644 --- a/generator.c +++ b/generator.c @@ -783,7 +783,7 @@ static int generate_and_send_sums(int fd, OFF_T len, int f_out, int f_copy) for (i = 0; i < sum.count; i++) { int32 n1 = (int32)MIN(len, (OFF_T)sum.blength); char *map = map_ptr(mapbuf, offset, n1); - char sum2[SUM_LENGTH]; + char sum2[MAX_DIGEST_LEN]; uint32 sum1; len -= n1; @@ -142,7 +142,7 @@ static void hash_search(int f,struct sum_struct *s, { OFF_T offset, aligned_offset, end; int32 k, want_i, aligned_i, backup; - char sum2[SUM_LENGTH]; + char sum2[MAX_DIGEST_LEN]; uint32 s1, s2, sum; int more; schar *map; |