=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ranlib/Attic/build.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- src/usr.bin/ranlib/Attic/build.c 1996/06/26 05:38:03 1.2 +++ src/usr.bin/ranlib/Attic/build.c 1997/11/05 18:57:27 1.3 @@ -1,4 +1,4 @@ -/* $OpenBSD: build.c,v 1.2 1996/06/26 05:38:03 deraadt Exp $ */ +/* $OpenBSD: build.c,v 1.3 1997/11/05 18:57:27 deraadt Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -38,7 +38,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)build.c 5.3 (Berkeley) 3/12/91";*/ -static char rcsid[] = "$OpenBSD: build.c,v 1.2 1996/06/26 05:38:03 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: build.c,v 1.3 1997/11/05 18:57:27 deraadt Exp $"; #endif /* not lint */ #include @@ -224,6 +224,8 @@ struct ranlib rn; char hb[sizeof(struct ar_hdr) + 1], pad; long ransize, size, stroff; + uid_t uid; + gid_t gid; /* Rewind the archive, leaving the magic number. */ if (fseek(fp, (off_t)SARMAG, SEEK_SET) == (off_t)-1) @@ -238,9 +240,20 @@ } else pad = '\0'; + uid = getuid(); + if (uid > USHRT_MAX) { + warnx("warning: uid %d truncated to %d", uid, USHRT_MAX); + uid = USHRT_MAX; + } + gid = getgid(); + if (gid > USHRT_MAX) { + warnx("warning: gid %d truncated to %d", gid, USHRT_MAX); + gid = USHRT_MAX; + } + /* Put out the ranlib archive file header. */ #define DEFMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) - (void)sprintf(hb, HDR2, RANLIBMAG, 0L, getuid(), getgid(), + (void)sprintf(hb, HDR2, RANLIBMAG, 0L, uid, gid, DEFMODE & ~umask(0), (off_t)ransize, ARFMAG); if (!fwrite(hb, sizeof(struct ar_hdr), 1, fp)) error(tname);