summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-02-09 15:24:38 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-02-09 15:32:41 +0100
commit48b3355c7a887530a9bd17a1ad571e402102dd95 (patch)
treed4f47abc466f9662b677e130dc6ae847dce5ee9a /lib/util
parentf47425873fad94d3e7add4c7d5c48c2f7c67dbe5 (diff)
Remove check for OS specific stuff from is_filename_sane
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/filename_sane.c56
1 files changed, 1 insertions, 55 deletions
diff --git a/lib/util/filename_sane.c b/lib/util/filename_sane.c
index b52ce4d..f98aafc 100644
--- a/lib/util/filename_sane.c
+++ b/lib/util/filename_sane.c
@@ -9,68 +9,14 @@
#include <string.h>
-#if defined(_WIN32) || defined(__WINDOWS__) || defined(TEST_WIN32)
-#ifdef _MSC_VER
-#define strncasecmp _strnicmp
-#define strcasecmp _stricmp
-#endif
-
-static const char *bad_names[] = {
- "CON", "PRN", "AUX", "NUL",
- "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
- "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9",
-};
-
-static bool is_allowed_by_os(const char *name)
-{
- size_t len, i;
-
- for (i = 0; i < sizeof(bad_names) / sizeof(bad_names[0]); ++i) {
- len = strlen(bad_names[i]);
-
- if (strncasecmp(name, bad_names[i], len) != 0)
- continue;
-
- if (name[len] == '\0')
- return false;
-
- if (name[len] == '.' && strchr(name + len + 1, '.') == NULL)
- return false;
- }
-
- return true;
-}
-#else
-static bool is_allowed_by_os(const char *name)
-{
- (void)name;
- return true;
-}
-#endif
-
-bool is_filename_sane(const char *name, bool check_os_specific)
+bool is_filename_sane(const char *name)
{
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
return false;
- if (check_os_specific && !is_allowed_by_os(name))
- return false;
-
while (*name != '\0') {
if (*name == '/')
return false;
-
-#if defined(_WIN32) || defined(__WINDOWS__) || defined(TEST_WIN32)
- if (check_os_specific) {
- if (*name == '<' || *name == '>' || *name == ':')
- return false;
- if (*name == '"' || *name == '|' || *name == '?')
- return false;
- if (*name == '*' || *name == '\\' || *name <= 31)
- return false;
- }
-#endif
-
++name;
}