]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cfdisk: fix possible integer overflow [coverity scan]
authorKarel Zak <kzak@redhat.com>
Mon, 24 Jun 2024 07:46:37 +0000 (09:46 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 27 Jun 2024 10:12:56 +0000 (12:12 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit 72f801dbcd99bc1dcbfdb0bf8e1f5d2f1ad753c6)

disk-utils/cfdisk.c

index 11b7faef752843d391d62068a75b1deaa4813a67..183b7671eb301c745462ef8563b190407569a9a6 100644 (file)
@@ -1741,6 +1741,8 @@ static int ui_table_goto(struct cfdisk *cf, int where)
 
        if (where < 0)
                where = 0;
+       if (!nparts)
+               where = 0;
        else if ((size_t) where > nparts - 1)
                where = nparts - 1;