summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJeremie Courreges-Anglas <jca@cvs.openbsd.org>2024-04-16 22:58:11 +0000
committerJeremie Courreges-Anglas <jca@cvs.openbsd.org>2024-04-16 22:58:11 +0000
commitdeb161def57ff2244ad3e689b4e228823cd66df6 (patch)
tree922493a87c1dc656c1d08d612c9179810f906f7f /bin
parent5a1da99a29819d41d6a31e0a09d400d85a608680 (diff)
Fix reading large pax extended records
512 bytes isn't enough if you want to store rather large but still useful long file names or symbolic links destinations. The best way to size the buffer to read those records is based upon the largest paths pax(1) can handle, and that is PAXPATHLEN. Reported by caspar@, input and ok millert@
Diffstat (limited to 'bin')
-rw-r--r--bin/pax/tar.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/bin/pax/tar.c b/bin/pax/tar.c
index 212961f8f44..01f4491ac6b 100644
--- a/bin/pax/tar.c
+++ b/bin/pax/tar.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tar.c,v 1.83 2024/04/16 20:51:11 jca Exp $ */
+/* $OpenBSD: tar.c,v 1.84 2024/04/16 22:58:10 jca Exp $ */
/* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */
/*-
@@ -62,9 +62,6 @@ struct xheader_record {
/* shortest possible extended record: "5 a=\n" */
#define MINXHDRSZ 5
-/* longest record we'll accept */
-#define MAXXHDRSZ BLKMULT
-
/*
* Routines for reading, writing and header identify of various versions of tar
*/
@@ -1588,7 +1585,11 @@ rd_size(off_t *size, const char *keyword, char *p)
static int
rd_xheader(ARCHD *arcn, int global, off_t size)
{
- char buf[MAXXHDRSZ];
+ /*
+ * The pax format supposedly supports arbitrarily sized extended
+ * record headers, this implementation doesn't.
+ */
+ char buf[sizeof("30xx linkpath=") - 1 + PAXPATHLEN + sizeof("\n")];
long len;
char *delim, *keyword;
char *nextp, *p, *end;