]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mkswap: fix holes detection (infinite loop and/or stack-buffer-underflow)
authorKarel Zak <kzak@redhat.com>
Tue, 15 Jun 2021 10:04:43 +0000 (12:04 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 15 Jun 2021 10:07:34 +0000 (12:07 +0200)
Reported-by: Brian Lane <bcl@redhat.com>
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1971877
Fix: https://github.com/karelzak/util-linux/issues/1348
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/mkswap.c

index 27374fd72122efe908caf805f01e27f43ae9c34e..c45a3a317e4ba29fd4d56a35523848f861b8fb2e 100644 (file)
@@ -267,6 +267,8 @@ static void check_extents(struct mkswap_control *ctl)
                        return;
 
                n = fiemap->fm_mapped_extents;
+               if (n == 0)
+                       break;
 
                for (i = 0; i < n; i++) {
                        struct fiemap_extent *e = &fiemap->fm_extents[i];