From 524cf3a831099951748f92c356f1909d77affa31 Mon Sep 17 00:00:00 2001 From: zhangyaqi Date: Thu, 17 Oct 2024 19:27:13 +0800 Subject: [PATCH] chroot whoami use uintmax_t for printing uids --- ...oami-use-uintmax_t-for-printing-uids.patch | 46 +++++++++++++++++++ coreutils.spec | 6 ++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 backport-chroot-whoami-use-uintmax_t-for-printing-uids.patch diff --git a/backport-chroot-whoami-use-uintmax_t-for-printing-uids.patch b/backport-chroot-whoami-use-uintmax_t-for-printing-uids.patch new file mode 100644 index 0000000..fd23e21 --- /dev/null +++ b/backport-chroot-whoami-use-uintmax_t-for-printing-uids.patch @@ -0,0 +1,46 @@ +From 8083944484f2cdf6c9b737642567bcdb54db784d Mon Sep 17 00:00:00 2001 +From: Collin Funk +Date: Sun, 6 Oct 2024 22:19:51 -0700 +Subject: [PATCH] chroot,whoami: use uintmax_t for printing uids + +Reference:https://github.com/coreutils/coreutils/commit/8083944484f2cdf6c9b737642567bcdb54db784d +* src/chroot.c (main): Cast the uid to uintmax_t instead of int. +* src/whoami.c (main): Cast the uid to uintmax_t instead of unsigned +long int. +--- + src/chroot.c | 3 ++- + src/whoami.c | 4 ++-- + 2 files changed, 4 insertions(+), 3 deletions(-) + +diff --git a/src/chroot.c b/src/chroot.c +index 6150af5..db3444d 100644 +--- a/src/chroot.c ++++ b/src/chroot.c +@@ -374,7 +374,8 @@ main (int argc, char **argv) + else if (gid_unset (gid)) + { + error (EXIT_CANCELED, errno, +- _("no group specified for unknown uid: %d"), (int) uid); ++ _("no group specified for unknown uid: %ju"), ++ (uintmax_t) uid); + } + } + +diff --git a/src/whoami.c b/src/whoami.c +index e7a578a..04f6c29 100644 +--- a/src/whoami.c ++++ b/src/whoami.c +@@ -81,8 +81,8 @@ main (int argc, char **argv) + uid = geteuid (); + pw = uid == NO_UID && errno ? nullptr : getpwuid (uid); + if (!pw) +- error (EXIT_FAILURE, errno, _("cannot find name for user ID %lu"), +- (unsigned long int) uid); ++ error (EXIT_FAILURE, errno, _("cannot find name for user ID %ju"), ++ (uintmax_t) uid); + puts (pw->pw_name); + return EXIT_SUCCESS; + } +-- +2.27.0 + diff --git a/coreutils.spec b/coreutils.spec index 7b979ca..a712883 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,6 +1,6 @@ Name: coreutils Version: 9.4 -Release: 10 +Release: 11 License: GPLv3+ Summary: A set of basic GNU tools commonly used in shell scripts Url: https://www.gnu.org/software/coreutils/ @@ -37,6 +37,7 @@ Patch22: backport-putenv-Don-t-crash-upon-out-of-memory.patch Patch23: backport-head-off_t-not-uintmax_t-for-file-offset.patch Patch24: backport-shuf-avoid-integer-overflow-on-huge-inputs.patch Patch25: backport-shuf-fix-randomness-bug.patch +Patch26: backport-chroot-whoami-use-uintmax_t-for-printing-uids.patch Patch9001: coreutils-9.0-sw.patch @@ -177,6 +178,9 @@ fi %{_mandir}/man*/* %changelog +* Fri Oct 25 2024 zhangyaqi - 9.4-11 +- chroot,whoami: use uintmax_t for printing uids + * Wed Sep 11 2024 huyubiao - 9.4-10 - sync patches from community - add backport-pinky-fix-string-size-calculation.patch -- Gitee