OSDN Git Service

fix format strings for uid/gid values in putpwent/putgrent
authorRich Felker <dalias@aerifal.cx>
Thu, 16 May 2019 21:12:56 +0000 (17:12 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 16 May 2019 21:19:03 +0000 (17:19 -0400)
commit 648c3b4e18b2ce2b6af7d44783e42ca267ea49f5 omitted this change,
which is needed to be able to use uid/gid values greater than INT_MAX
with these interfaces. it fixes alpine linux bug #10460.

src/passwd/putgrent.c
src/passwd/putpwent.c

index a0b320f..2a8257d 100644 (file)
@@ -7,7 +7,7 @@ int putgrent(const struct group *gr, FILE *f)
        int r;
        size_t i;
        flockfile(f);
-       if ((r = fprintf(f, "%s:%s:%d:", gr->gr_name, gr->gr_passwd, gr->gr_gid))<0) goto done;
+       if ((r = fprintf(f, "%s:%s:%u:", gr->gr_name, gr->gr_passwd, gr->gr_gid))<0) goto done;
        if (gr->gr_mem) for (i=0; gr->gr_mem[i]; i++)
                if ((r = fprintf(f, "%s%s", i?",":"", gr->gr_mem[i]))<0) goto done;
        r = fputc('\n', f);
index 3a02e57..312b765 100644 (file)
@@ -4,7 +4,7 @@
 
 int putpwent(const struct passwd *pw, FILE *f)
 {
-       return fprintf(f, "%s:%s:%d:%d:%s:%s:%s\n",
+       return fprintf(f, "%s:%s:%u:%u:%s:%s:%s\n",
                pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid,
                pw->pw_gecos, pw->pw_dir, pw->pw_shell)<0 ? -1 : 0;
 }