Truncate large UIDs and GIDs to USHRT_MAX, to accomodate the antiquated file

format.
This commit is contained in:
mycroft 1997-04-24 06:16:45 +00:00
parent d1c236b1e4
commit a81c377258
1 changed files with 21 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: archive.c,v 1.9 1997/01/09 12:40:09 tls Exp $ */
/* $NetBSD: archive.c,v 1.10 1997/04/24 06:16:45 mycroft Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)archive.c 8.4 (Berkeley) 4/27/95";
#else
static char rcsid[] = "$NetBSD: archive.c,v 1.9 1997/01/09 12:40:09 tls Exp $";
static char rcsid[] = "$NetBSD: archive.c,v 1.10 1997/04/24 06:16:45 mycroft Exp $";
#endif
#endif /* not lint */
@ -208,6 +208,8 @@ put_arobj(cfp, sb)
char *name;
struct ar_hdr *hdr;
off_t size;
uid_t uid;
gid_t gid;
/*
* If passed an sb structure, reading a file from disk. Get stat(2)
@ -224,26 +226,36 @@ put_arobj(cfp, sb)
* a space, use extended format 1.
*/
lname = strlen(name);
uid = sb->st_uid;
gid = sb->st_gid;
if (uid > USHRT_MAX) {
warnx("warning: uid %d truncated to %d", uid,
USHRT_MAX);
uid = USHRT_MAX;
}
if (gid > USHRT_MAX) {
warnx("warning: gid %d truncated to %d", gid,
USHRT_MAX);
gid = USHRT_MAX;
}
if (options & AR_TR) {
if (lname > OLDARMAXNAME) {
(void)fflush(stdout);
warnx("warning: %s truncated to %.*s",
warnx("warning: file name %s truncated to %.*s",
name, OLDARMAXNAME, name);
(void)fflush(stderr);
}
(void)sprintf(hb, HDR3, name, sb->st_mtimespec.tv_sec,
sb->st_uid, sb->st_gid, sb->st_mode, sb->st_size,
ARFMAG);
uid, gid, sb->st_mode, sb->st_size, ARFMAG);
lname = 0;
} else if (lname > sizeof(hdr->ar_name) || strchr(name, ' '))
(void)sprintf(hb, HDR1, AR_EFMT1, lname,
sb->st_mtimespec.tv_sec, sb->st_uid, sb->st_gid,
sb->st_mode, sb->st_size + lname, ARFMAG);
sb->st_mtimespec.tv_sec, uid, gid, sb->st_mode,
sb->st_size + lname, ARFMAG);
else {
lname = 0;
(void)sprintf(hb, HDR2, name, sb->st_mtimespec.tv_sec,
sb->st_uid, sb->st_gid, sb->st_mode, sb->st_size,
ARFMAG);
uid, gid, sb->st_mode, sb->st_size, ARFMAG);
}
size = sb->st_size;
} else {