sscanf does not increment it's return value when matching "%n".'long_path.tar' contains a file 'long_file_name_..._TRAILING' and without this
patch, tar will omit the 'TRAILING' part.
//William
From 23c7598d8de3f1866368bbc2ca4379d0aeaace9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Djupstr=C3=B6m?= <will...@deepztream.com> Date: Mon, 8 Jun 2020 13:38:33 +0200 Subject: [PATCH] tar: fix extracting long file paths --- toys/posix/tar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toys/posix/tar.c b/toys/posix/tar.c index 9642fbe6..77dd6fe9 100644 --- a/toys/posix/tar.c +++ b/toys/posix/tar.c @@ -590,7 +590,7 @@ static void unpack_tar(char *first) else if (tar.type == 'L') alloread(&TT.hdr.name, TT.hdr.size); else if (tar.type == 'x') { char *p, *buf = 0; - int i, len, n; + int i, len, n = 0; // Posix extended record "LEN NAME=VALUE\n" format alloread(&buf, TT.hdr.size); @@ -601,7 +601,7 @@ static void unpack_tar(char *first) break; } p[len-1] = 0; - if (i == 2) { + if (n) { TT.hdr.name = xstrdup(p+n); break; } -- 2.20.1
long_path.tar
Description: Binary data
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net