]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: fix the way to print stat.st_nlink
authorMasatake YAMATO <yamato@redhat.com>
Thu, 10 Feb 2022 07:14:11 +0000 (16:14 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Thu, 10 Feb 2022 07:14:17 +0000 (16:14 +0900)
The type used for casting the member was too small; for the
"%ju" format spec, we should use uintmax_t for the purpose.

This change may fix the bug reported in
https://github.com/util-linux/util-linux/issues/1511#issuecomment-1033697617
in GitHub#1511 by Anatoly Pugachev <matorola@gmail.com>.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd-file.c

index 9c320e94935a7f1a6f896b7d4425ce5ae9c163b2..39a5b92174d271653ddcb8963a8f783630b0b384 100644 (file)
@@ -292,7 +292,7 @@ static bool file_fill_column(struct proc *proc,
                xasprintf(&str, "%jd", (intmax_t)file->stat.st_size);
                break;
        case COL_NLINK:
-               xasprintf(&str, "%ju", (unsigned long int)file->stat.st_nlink);
+               xasprintf(&str, "%ju", (uintmax_t)file->stat.st_nlink);
                break;
        case COL_DELETED:
                xasprintf(&str, "%d", file->stat.st_nlink == 0);