summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2013-04-11 00:44:26 +0000
committerguenther <guenther@openbsd.org>2013-04-11 00:44:26 +0000
commit29e1d92be52fad8f184c70231b7a91fb3a988a38 (patch)
tree169a638a6fb1066a88e66559facaf0d3874bd4d6
parentCorrectly handle data memory protection ID traps: if occuring in user mode, (diff)
downloadwireguard-openbsd-29e1d92be52fad8f184c70231b7a91fb3a988a38.tar.xz
wireguard-openbsd-29e1d92be52fad8f184c70231b7a91fb3a988a38.zip
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@
-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