summaryrefslogtreecommitdiff
path: root/bin/pax
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2013-04-11 00:44:27 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2013-04-11 00:44:27 +0000
commit51413dc1528c5ef2a0199fcedd276c6542954b92 (patch)
tree9ed30c11d9057e9c3249e838e473734ab19cc42a /bin/pax
parent0bbb3ff6984f408f9018091b2d9bc33fbf3c506b (diff)
The tweaks I suggested to the previous diff resulted in the typeflag
being checked after it was overwritten by the next block read in. Eliminate the argument aliasing that led to this being overlooked by passing rd_xheader() the size and typeflag directly. problem discovery and ok fgsch@
Diffstat (limited to 'bin/pax')
-rw-r--r--bin/pax/tar.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/bin/pax/tar.c b/bin/pax/tar.c
index ec4c809b6ba..0823825bf4b 100644
--- a/bin/pax/tar.c
+++ b/bin/pax/tar.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tar.c,v 1.46 2013/04/09 18:30:34 fgsch Exp $ */
+/* $OpenBSD: tar.c,v 1.47 2013/04/11 00:44:26 guenther Exp $ */
/* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */
/*-
@@ -60,7 +60,7 @@ static int ul_oct(u_long, char *, int, int);
static int uqd_oct(u_quad_t, char *, int, int);
#endif
#ifndef SMALL
-static int rd_xheader(ARCHD *, char *, HD_USTAR **);
+static int rd_xheader(ARCHD *, char *, off_t, char);
#endif
static uid_t uid_nobody;
@@ -760,7 +760,9 @@ ustar_rd(ARCHD *arcn, char *buf)
#ifndef SMALL
/* Process the Extended header. */
if (hd->typeflag == XHDRTYPE || hd->typeflag == GHDRTYPE) {
- if (rd_xheader(arcn, buf, &hd) < 0)
+ if (rd_xheader(arcn, buf,
+ (off_t)asc_ul(hd->size, sizeof(hd->size), OCT),
+ hd->typeflag) < 0)
return (-1);
}
#endif
@@ -1204,13 +1206,12 @@ expandname(char *buf, size_t len, char **gnu_name, const char *name,
#define MINXHDRSZ 6
static int
-rd_xheader(ARCHD *arcn, char *buf, HD_USTAR **hd)
+rd_xheader(ARCHD *arcn, char *buf, off_t size, char typeflag)
{
- off_t len, size;
+ off_t len;
char *delim, *keyword;
char *nextp, *p;
- size = (off_t)asc_ul((*hd)->size, sizeof((*hd)->size), OCT);
if (size < MINXHDRSZ) {
paxwarn(1, "Invalid extended header length");
return (-1);
@@ -1246,7 +1247,7 @@ rd_xheader(ARCHD *arcn, char *buf, HD_USTAR **hd)
return (-1);
}
*p++ = nextp[-1] = '\0';
- if ((*hd)->typeflag == XHDRTYPE) {
+ if (typeflag == XHDRTYPE) {
if (!strcmp(keyword, "path")) {
arcn->nlen = strlcpy(arcn->name, p,
sizeof(arcn->name));
@@ -1260,7 +1261,6 @@ rd_xheader(ARCHD *arcn, char *buf, HD_USTAR **hd)
/* Update the ustar header. */
if (rd_wrbuf(buf, BLKMULT) != BLKMULT)
return (-1);
- *hd = (HD_USTAR *)buf;
return (0);
}
#endif