From 72f801dbcd99bc1dcbfdb0bf8e1f5d2f1ad753c6 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 24 Jun 2024 09:46:37 +0200
Subject: [PATCH] cfdisk: fix possible integer overflow [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
Reference:https://github.com/util-linux/util-linux/commit/72f801dbcd99bc1dcbfdb0bf8e1f5d2f1ad753c6
Conflict:NA
---
 disk-utils/cfdisk.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c
index 7b619296..2e0aada4 100644
--- a/disk-utils/cfdisk.c
+++ b/disk-utils/cfdisk.c
@@ -1733,6 +1733,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;
 
-- 
2.33.0

