-/* $OpenBSD: cpio.c,v 1.27 2015/03/19 05:14:24 guenther Exp $ */
+/* $OpenBSD: cpio.c,v 1.28 2016/08/14 04:47:52 guenther Exp $ */
/* $NetBSD: cpio.c,v 1.5 1995/03/21 09:07:13 cgd Exp $ */
/*-
cpio_rd(ARCHD *arcn, char *buf)
{
int nsz;
- u_quad_t val;
+ unsigned long long val;
HD_CPIO *hd;
/*
arcn->sb.st_nlink = (nlink_t)asc_ul(hd->c_nlink, sizeof(hd->c_nlink),
OCT);
arcn->sb.st_rdev = (dev_t)asc_ul(hd->c_rdev, sizeof(hd->c_rdev), OCT);
- val = asc_uqd(hd->c_mtime, sizeof(hd->c_mtime), OCT);
+ val = asc_ull(hd->c_mtime, sizeof(hd->c_mtime), OCT);
if ((time_t)val < 0 || (time_t)val != val)
arcn->sb.st_mtime = INT_MAX; /* XXX 2038 */
else
arcn->sb.st_mtime = val;
arcn->sb.st_mtim.tv_nsec = 0;
arcn->sb.st_ctim = arcn->sb.st_atim = arcn->sb.st_mtim;
- arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize,sizeof(hd->c_filesize),
+ arcn->sb.st_size = (off_t)asc_ull(hd->c_filesize,sizeof(hd->c_filesize),
OCT);
/*
/*
* set data size for file data
*/
- if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize,
+ if (ull_asc(arcn->sb.st_size, hd->c_filesize,
sizeof(hd->c_filesize), OCT)) {
paxwarn(1,"File is too large for cpio format %s",
arcn->org_name);
OCT) ||
ul_asc((u_long)arcn->sb.st_rdev, hd->c_rdev, sizeof(hd->c_rdev),
OCT) ||
- uqd_asc(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->c_mtime,
+ ull_asc(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->c_mtime,
sizeof(hd->c_mtime), OCT) ||
ul_asc((u_long)nsz, hd->c_namesize, sizeof(hd->c_namesize), OCT))
goto out;
arcn->sb.st_mtime = (time_t)asc_ul(hd->c_mtime,sizeof(hd->c_mtime),HEX);
arcn->sb.st_mtim.tv_nsec = 0;
arcn->sb.st_ctim = arcn->sb.st_atim = arcn->sb.st_mtim;
- arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize,
+ arcn->sb.st_size = (off_t)asc_ull(hd->c_filesize,
sizeof(hd->c_filesize), HEX);
arcn->sb.st_nlink = (nlink_t)asc_ul(hd->c_nlink, sizeof(hd->c_nlink),
HEX);
* much to pad.
*/
arcn->pad = VCPIO_PAD(arcn->sb.st_size);
- if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize,
+ if (ull_asc(arcn->sb.st_size, hd->c_filesize,
sizeof(hd->c_filesize), HEX)) {
paxwarn(1,"File is too large for sv4cpio format %s",
arcn->org_name);
-/* $OpenBSD: extern.h,v 1.54 2016/01/01 15:56:03 tedu Exp $ */
+/* $OpenBSD: extern.h,v 1.55 2016/08/14 04:47:52 guenther Exp $ */
/* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */
/*-
void safe_print(const char *, FILE *);
u_long asc_ul(char *, int, int);
int ul_asc(u_long, char *, int, int);
-u_quad_t asc_uqd(char *, int, int);
-int uqd_asc(u_quad_t, char *, int, int);
+unsigned long long asc_ull(char *, int, int);
+int ull_asc(unsigned long long, char *, int, int);
size_t fieldcpy(char *, size_t, const char *, size_t);
/*
-/* $OpenBSD: gen_subs.c,v 1.28 2015/03/17 03:23:17 guenther Exp $ */
+/* $OpenBSD: gen_subs.c,v 1.29 2016/08/14 04:47:52 guenther Exp $ */
/* $NetBSD: gen_subs.c,v 1.5 1995/03/21 09:07:26 cgd Exp $ */
/*-
*pt-- = '0' + (char)digit;
else
*pt-- = 'a' + (char)(digit - 10);
- if ((val = (val >> 4)) == (u_long)0)
+ val >>= 4;
+ if (val == 0)
break;
}
} else {
while (pt >= str) {
*pt-- = '0' + (char)(val & 0x7);
- if ((val = (val >> 3)) == (u_long)0)
+ val >>= 3;
+ if (val == 0)
break;
}
}
*/
while (pt >= str)
*pt-- = '0';
- if (val != (u_long)0)
+ if (val != 0)
return(-1);
return(0);
}
/*
- * asc_uqd()
- * convert hex/octal character string into a u_quad_t. We do not have to
- * check for overflow! (the headers in all supported formats are not large
- * enough to create an overflow).
+ * asc_ull()
+ * Convert hex/octal character string into a unsigned long long.
+ * We do not have to check for overflow! (The headers in all
+ * supported formats are not large enough to create an overflow).
* NOTE: strings passed to us are NOT TERMINATED.
* Return:
- * u_quad_t value
+ * unsigned long long value
*/
-u_quad_t
-asc_uqd(char *str, int len, int base)
+unsigned long long
+asc_ull(char *str, int len, int base)
{
char *stop;
- u_quad_t tval = 0;
+ unsigned long long tval = 0;
stop = str + len;
}
/*
- * uqd_asc()
- * convert an u_quad_t into a hex/oct ascii string. pads with LEADING
- * ascii 0's to fill string completely
+ * ull_asc()
+ * Convert an unsigned long long into a hex/oct ascii string.
+ * Pads with LEADING ascii 0's to fill string completely
* NOTE: the string created is NOT TERMINATED.
*/
int
-uqd_asc(u_quad_t val, char *str, int len, int base)
+ull_asc(unsigned long long val, char *str, int len, int base)
{
char *pt;
- u_quad_t digit;
+ unsigned long long digit;
/*
* WARNING str is not '\0' terminated by this routine
*pt-- = '0' + (char)digit;
else
*pt-- = 'a' + (char)(digit - 10);
- if ((val = (val >> 4)) == (u_quad_t)0)
+ val >>= 4;
+ if (val == 0)
break;
}
} else {
while (pt >= str) {
*pt-- = '0' + (char)(val & 0x7);
- if ((val = (val >> 3)) == (u_quad_t)0)
+ val >>= 3;
+ if (val == 0)
break;
}
}
*/
while (pt >= str)
*pt-- = '0';
- if (val != (u_quad_t)0)
+ if (val != 0)
return(-1);
return(0);
}
-/* $OpenBSD: options.c,v 1.93 2016/04/19 03:26:11 guenther Exp $ */
+/* $OpenBSD: options.c,v 1.94 2016/08/14 04:47:52 guenther Exp $ */
/* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */
/*-
(void)fprintf(stderr,"%s: Invalid combination of options:", argv0);
while ((nxt = ffs(flg)) != 0) {
- flg = flg >> nxt;
+ flg >>= nxt;
pos += nxt;
(void)fprintf(stderr, " -%c", flgch[pos-1]);
}
-/* $OpenBSD: tar.c,v 1.59 2016/02/15 02:38:53 guenther Exp $ */
+/* $OpenBSD: tar.c,v 1.60 2016/08/14 04:47:52 guenther Exp $ */
/* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */
/*-
static u_long tar_chksm(char *, int);
static char *name_split(char *, int);
static int ul_oct(u_long, char *, int, int);
-static int uqd_oct(u_quad_t, char *, int, int);
+static int ull_oct(unsigned long long, char *, int, int);
#ifndef SMALL
static int rd_xheader(ARCHD *arcn, int, off_t);
#endif
*/
while (pt >= str) {
*pt-- = '0' + (char)(val & 0x7);
- if ((val = val >> 3) == (u_long)0)
+ val >>= 3;
+ if (val == 0)
break;
}
while (pt >= str)
*pt-- = '0';
- if (val != (u_long)0)
+ if (val != 0)
return(-1);
return(0);
}
/*
- * uqd_oct()
- * convert an u_quad_t to an octal string. one of many oddball field
- * termination characters are used by the various versions of tar in the
- * different fields. term selects which kind to use. str is '0' padded
- * at the front to len. we are unable to use only one format as many old
- * tar readers are very cranky about this.
+ * ull_oct()
+ * Convert an unsigned long long to an octal string. One of many oddball
+ * field termination characters are used by the various versions of tar
+ * in the different fields. term selects which kind to use. str is
+ * '0' padded at the front to len. We are unable to use only one format
+ * as many old tar readers are very cranky about this.
* Return:
* 0 if the number fit into the string, -1 otherwise
*/
static int
-uqd_oct(u_quad_t val, char *str, int len, int term)
+ull_oct(unsigned long long val, char *str, int len, int term)
{
char *pt;
*/
while (pt >= str) {
*pt-- = '0' + (char)(val & 0x7);
- if ((val = val >> 3) == 0)
+ val >>= 3;
+ if (val == 0)
break;
}
while (pt >= str)
*pt-- = '0';
- if (val != (u_quad_t)0)
+ if (val != 0)
return(-1);
return(0);
}
tar_rd(ARCHD *arcn, char *buf)
{
HD_TAR *hd;
- u_quad_t val;
+ unsigned long long val;
char *pt;
/*
0xfff);
arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT);
arcn->sb.st_gid = (gid_t)asc_ul(hd->gid, sizeof(hd->gid), OCT);
- arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT);
- val = asc_uqd(hd->mtime, sizeof(hd->mtime), OCT);
+ arcn->sb.st_size = (off_t)asc_ull(hd->size, sizeof(hd->size), OCT);
+ val = asc_ull(hd->mtime, sizeof(hd->mtime), OCT);
if ((time_t)val < 0 || (time_t)val != val)
arcn->sb.st_mtime = INT_MAX; /* XXX 2038 */
else
* data follows this file, so set the pad
*/
hd->linkflag = AREGTYPE;
- if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size,
- sizeof(hd->size), 1)) {
- paxwarn(1,"File is too large for tar %s", arcn->org_name);
+ if (ull_oct(arcn->sb.st_size, hd->size, sizeof(hd->size), 1)) {
+ paxwarn(1, "File is too large for tar %s",
+ arcn->org_name);
return(1);
}
arcn->pad = TAR_PAD(arcn->sb.st_size);
* copy those fields that are independent of the type
*/
if (ul_oct((u_long)arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 0) ||
- uqd_oct(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->mtime,
+ ull_oct(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->mtime,
sizeof(hd->mtime), 1) ||
ul_oct((u_long)arcn->sb.st_uid, hd->uid, sizeof(hd->uid), 0) ||
ul_oct((u_long)arcn->sb.st_gid, hd->gid, sizeof(hd->gid), 0))
int cnt = 0;
dev_t devmajor;
dev_t devminor;
- u_quad_t val;
+ unsigned long long val;
/*
* we only get proper sized buffers
*/
arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode, sizeof(hd->mode), OCT) &
0xfff);
- arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT);
- val = asc_uqd(hd->mtime, sizeof(hd->mtime), OCT);
+ arcn->sb.st_size = (off_t)asc_ull(hd->size, sizeof(hd->size), OCT);
+ val = asc_ull(hd->mtime, sizeof(hd->mtime), OCT);
if ((time_t)val < 0 || (time_t)val != val)
arcn->sb.st_mtime = INT_MAX; /* XXX 2038 */
else
else
hd->typeflag = REGTYPE;
arcn->pad = TAR_PAD(arcn->sb.st_size);
- if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size,
- sizeof(hd->size), 3)) {
- paxwarn(1,"File is too long for ustar %s",arcn->org_name);
+ if (ull_oct(arcn->sb.st_size, hd->size, sizeof(hd->size), 3)) {
+ paxwarn(1, "File is too long for ustar %s",
+ arcn->org_name);
return(1);
}
break;
if (ul_oct((u_long)gid_nobody, hd->gid, sizeof(hd->gid), 3))
goto out;
}
- if (uqd_oct(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->mtime,
+ if (ull_oct(arcn->sb.st_mtime < 0 ? 0 : arcn->sb.st_mtime, hd->mtime,
sizeof(hd->mtime), 3) ||
ul_oct((u_long)arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 3))
goto out;