aboutsummaryrefslogtreecommitdiff
path: root/lib/fstree
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-12-29 12:10:46 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-12-29 12:39:17 +0100
commitb04ff42f1640a4dd67af043f08b62ac4ec96edc7 (patch)
tree01f8c6d3fb0f69d1dfb8d47b3cdd8f40c79e991e /lib/fstree
parent40ca906fa9f2f0e4e325432aff00433f2bb731bd (diff)
Fix normalization of slashes in filenames
All paths were canonicalized internally, which includes filtering sequences of slashes and converting backslashes to slashes. Furthermore, when unpacking files, filenames are sanity checked and rejected if they contain forward OR backward slashes. This is a problem on Unix-like systems, where files containing backslashes are a legitimate use case (*cough* SystemD *cough*). This patch removes the backslash conversion from the canonicalization and modifies the sanity check to reject backslashes only on Windows. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree')
-rw-r--r--lib/fstree/canonicalize_name.c6
-rw-r--r--lib/fstree/filename_sane.c4
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/fstree/canonicalize_name.c b/lib/fstree/canonicalize_name.c
index f35307f..7fbd5a7 100644
--- a/lib/fstree/canonicalize_name.c
+++ b/lib/fstree/canonicalize_name.c
@@ -11,12 +11,12 @@ static void normalize_slashes(char *filename)
{
char *dst = filename, *src = filename;
- while (*src == '/' || *src == '\\')
+ while (*src == '/')
++src;
while (*src != '\0') {
- if (*src == '/' || *src == '\\') {
- while (*src == '/' || *src == '\\')
+ if (*src == '/') {
+ while (*src == '/')
++src;
if (*src == '\0')
break;
diff --git a/lib/fstree/filename_sane.c b/lib/fstree/filename_sane.c
index b0f8c90..91c15da 100644
--- a/lib/fstree/filename_sane.c
+++ b/lib/fstree/filename_sane.c
@@ -57,7 +57,7 @@ bool is_filename_sane(const char *name, bool check_os_specific)
return false;
while (*name != '\0') {
- if (*name == '/' || *name == '\\')
+ if (*name == '/')
return false;
#if defined(_WIN32) || defined(__WINDOWS__) || defined(TEST_WIN32)
@@ -66,7 +66,7 @@ bool is_filename_sane(const char *name, bool check_os_specific)
return false;
if (*name == '"' || *name == '|' || *name == '?')
return false;
- if (*name == '*' || *name <= 31)
+ if (*name == '*' || *name == '\\' || *name <= 31)
return false;
}
#endif