From 93d01a6233ad51d7f97ae6c78d9216f77b97b113 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 21 Jun 2021 15:33:36 +0200 Subject: [PATCH] lslocks: check errno after strto..() Addresses: https://github.com/karelzak/util-linux/issues/1356 Signed-off-by: Karel Zak --- misc-utils/lslocks.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c index 18922e546..941ef7f06 100644 --- a/misc-utils/lslocks.c +++ b/misc-utils/lslocks.c @@ -192,8 +192,10 @@ static char *get_filename_sz(ino_t inode, pid_t lock_pid, size_t *size) !strcmp(dp->d_name, "..")) continue; + errno = 0; + /* care only for numerical descriptors */ - if (!strtol(dp->d_name, (char **) NULL, 10)) + if (!strtol(dp->d_name, (char **) NULL, 10) || errno) continue; if (!fstatat(fd, dp->d_name, &sb, 0)