From: Paul Eggert Date: Mon, 31 Jul 2023 23:36:38 +0000 (-0700) Subject: groups,id: don’t assume gid_t fits in unsigned long X-Git-Tag: v9.4~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6387164e5e094cfa6e0a7baeda3991335bbaeb5b;p=thirdparty%2Fcoreutils.git groups,id: don’t assume gid_t fits in unsigned long * src/group-list.c (print_group): Convert to intmax_t or uintmax_t, not to unsigned long. --- diff --git a/src/group-list.c b/src/group-list.c index d94d79e757..5230123917 100644 --- a/src/group-list.c +++ b/src/group-list.c @@ -109,8 +109,16 @@ print_group (gid_t gid, bool use_name) grp = getgrgid (gid); if (grp == nullptr) { - error (0, 0, _("cannot find name for group ID %lu"), - (unsigned long int) gid); + if (TYPE_SIGNED (gid_t)) + { + intmax_t g = gid; + error (0, 0, _("cannot find name for group ID %"PRIdMAX), g); + } + else + { + uintmax_t g = gid; + error (0, 0, _("cannot find name for group ID %"PRIuMAX), g); + } ok = false; } }