diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-11-05 18:57:28 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-11-05 18:57:28 +0000 |
commit | c3a1416f1bfee4610c71507d02fc54abebb779a9 (patch) | |
tree | 92f3802949bc01df10af2dac16da51c7df535bb7 /usr.bin | |
parent | d687bce61c7530614a831738caf394a717c8a501 (diff) |
truncate uid/gid for large ones; nihilis@moral.addiction.com
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ranlib/build.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/usr.bin/ranlib/build.c b/usr.bin/ranlib/build.c index 3577f3fc792..abb0407aff5 100644 --- a/usr.bin/ranlib/build.c +++ b/usr.bin/ranlib/build.c @@ -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 <sys/types.h> @@ -224,6 +224,8 @@ symobj() 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 @@ symobj() } 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); |