From 9b725af7028163bd29d39da3b910dffc903107ee Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 28 Mar 2022 11:39:27 +0200
Subject: [PATCH] lslocks: fix maj:min scanf

Fixes: https://github.com/util-linux/util-linux/issues/1633
Signed-off-by: Karel Zak <kzak@redhat.com>
---
 misc-utils/lslocks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c
index 941ef7f..6427318 100644
--- a/misc-utils/lslocks.c
+++ b/misc-utils/lslocks.c
@@ -224,7 +224,8 @@ static ino_t get_dev_inode(char *str, dev_t *dev)
 	unsigned int maj = 0, min = 0;
 	ino_t inum = 0;
 
-	sscanf(str, "%02x:%02x:%ju", &maj, &min, &inum);
+	if (sscanf(str, "%x:%x:%ju", &maj, &min, &inum) != 3)
+		errx(EXIT_FAILURE, _("failed to parse '%s'"), str);
 
 	*dev = (dev_t) makedev(maj, min);
 	return inum;
-- 
2.27.0

