From deb161def57ff2244ad3e689b4e228823cd66df6 Mon Sep 17 00:00:00 2001 From: Jeremie Courreges-Anglas Date: Tue, 16 Apr 2024 22:58:11 +0000 Subject: 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@ --- bin/pax/tar.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'bin') 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; -- cgit v1.2.3