tar: ".." is also an unsafe filename, treat as such

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko committed 2026-10-09 15:09:26 +02:00
1 parent a040aa2826
commit 5da20102b5
1 file changed
+6
+6
View File
@@ -8,6 +8,12 @@
const char* FAST_FUNC skip_unsafe_prefix(const char *str)
{
const char *cp = str;
/* if "..": malicious, return "" */
/* (causes harmless errors trying to create or hardlink a file named "") */
if (cp[0] == '.' && cp[1] == '.' && cp[2] == '\0')
return cp + 2;
while (1) {
const char *cp2;
if (*cp == '/') {