[Toybox] [PATCH] tar: fix extracting long file paths
William Djupström
william at deepztream.com
Mon Jun 8 04:52:58 PDT 2020
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
-------------- next part --------------
From 23c7598d8de3f1866368bbc2ca4379d0aeaace9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?William=20Djupstr=C3=B6m?= <william at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: long_path.tar
Type: application/octet-stream
Size: 1536 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20200608/69b5941f/attachment-0002.obj>
More information about the Toybox
mailing list