blob: a5bb00ab651d04f923da7791e42e950347d7f248 [file] [log] [blame]
Andrew Geissler09036742021-06-25 14:25:14 -05001From 8a3a74160b96498d672e3652827aa7e6d7f3a120 Mon Sep 17 00:00:00 2001
2From: Karel Zak <kzak@redhat.com>
3Date: Tue, 15 Jun 2021 12:04:43 +0200
4Subject: [PATCH] mkswap: fix holes detection (infinite loop and/or
5 stack-buffer-underflow)
6
7Reported-by: Brian Lane <bcl@redhat.com>
8Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1971877
9Fix: https://github.com/karelzak/util-linux/issues/1348
10Signed-off-by: Karel Zak <kzak@redhat.com>
11Upstream-Status: Backport
12Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
13---
14 disk-utils/mkswap.c | 2 ++
15 1 file changed, 2 insertions(+)
16
17diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
18index 27374fd72..c45a3a317 100644
19--- a/disk-utils/mkswap.c
20+++ b/disk-utils/mkswap.c
21@@ -267,6 +267,8 @@ static void check_extents(struct mkswap_control *ctl)
22 return;
23
24 n = fiemap->fm_mapped_extents;
25+ if (n == 0)
26+ break;
27
28 for (i = 0; i < n; i++) {
29 struct fiemap_extent *e = &fiemap->fm_extents[i];