blob: 3c2e02207bf5aff348eb5b46e7b41b64273f63e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
commit 40b09fbe01fac8722b699b29f796e18550d68c84
Author: Theodore Ts'o <tytso@mit.edu>
Date: Fri Feb 5 22:25:03 2010 -0500
resize2fs: Fix fix uninit group test accessing invalid memory
Commit 74128f8 added tests for uninit groups, but it could access past
the end of the group_desc[] array after processing the last group:
==19668== Invalid read of size 2
==19668== at 0x40518C: resize_fs (resize2fs.c:1824)
==19668== by 0x405A46: main (main.c:451)
==19668== Address 0x5a0d002 is not stack'd, malloc'd or (recently) free'd
==19668==
==19668== Invalid read of size 2
==19668== at 0x405391: resize_fs (resize2fs.c:1864)
==19668== by 0x405A46: main (main.c:451)
==19668== Address 0x5a0d002 is not stack'd, malloc'd or (recently) free'd
==19668==
It was found by Eric Sandeen running the regression suite through
valgrind.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 75c4721..346fd53 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -1819,6 +1819,8 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
group_free;
ext2fs_group_desc_csum_set(fs, group);
group++;
+ if (group >= fs->group_desc_count)
+ break;
count = 0;
group_free = 0;
uninit = (fs->group_desc[group].bg_flags &
@@ -1859,6 +1861,8 @@ static errcode_t ext2fs_calculate_summary_stats(ext2_filsys fs)
group_free;
ext2fs_group_desc_csum_set(fs, group);
group++;
+ if (group >= fs->group_desc_count)
+ break;
count = 0;
group_free = 0;
uninit = (fs->group_desc[group].bg_flags &
|