From b6e895167a40a852caf21d4de1219bb88d78dff1 Mon Sep 17 00:00:00 2001 From: pfg Date: Mon, 26 Dec 2016 16:43:39 +0000 Subject: [PATCH] MFC r310367: pax(1): Fix a bug with archives smaller than 512 bytes. The problem here is that the archive is too short (< 512 bytes). The buffer routines, try to read at least 512 bytes, even when we try to determine what format file we have, which is wrong. Obtained from: NetBSD (CVS rev 1.26) git-svn-id: svn://svn.freebsd.org/base/stable/10@310606 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- bin/pax/buf_subs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c index 4922fc80f..40affa5c0 100644 --- a/bin/pax/buf_subs.c +++ b/bin/pax/buf_subs.c @@ -852,10 +852,13 @@ buf_fill(void) /* * errors require resync, EOF goes to next archive + * but in case we have not determined yet the format, + * this means that we have a very short file, so we + * are done again. */ if (cnt < 0) break; - if (ar_next() < 0) { + if (frmt == NULL || ar_next() < 0) { fini = 1; return(0); } -- 2.42.0