From: Masatake YAMATO Date: Thu, 10 Feb 2022 07:14:11 +0000 (+0900) Subject: lsfd: fix the way to print stat.st_nlink X-Git-Tag: v2.38-rc2~28^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1801c172a336b2d01f9e4bf3befaca188a6c0d0f;p=thirdparty%2Futil-linux.git lsfd: fix the way to print stat.st_nlink 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 . Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/lsfd-file.c b/misc-utils/lsfd-file.c index 9c320e9493..39a5b92174 100644 --- a/misc-utils/lsfd-file.c +++ b/misc-utils/lsfd-file.c @@ -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);