From 6f96c4d2651ed59975354433267319d527490537 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 18 Dec 2019 16:35:19 +0100 Subject: Move is_filename_sane to libfstree, add test cases Signed-off-by: David Oberhollenzer --- include/common.h | 2 -- include/fstree.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/common.h b/include/common.h index 8b2c66c..bdb3837 100644 --- a/include/common.h +++ b/include/common.h @@ -132,8 +132,6 @@ void sqfs_writer_cleanup(sqfs_writer_t *sqfs); void sqfs_perror(const char *file, const char *action, int error_code); -bool is_filename_sane(const char *name, bool check_os_specific); - /* A wrapper around mkdir() that behaves like 'mkdir -p'. It tries to create every component of the given path and skips already existing entries. diff --git a/include/fstree.h b/include/fstree.h index 7bc92fd..4ff8c5f 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -181,4 +181,14 @@ char *fstree_get_path(tree_node_t *node); */ int canonicalize_name(char *filename); +/* + Returns true if a given filename is sane, false if it is not (e.g. contains + slashes or it is equal to '.' or '..'). + + If check_os_specific is true, this also checks if the filename contains + a character, or is equal to a name, that is black listed on the current OS. + E.g. on Windows, a file named "COM0" or "AUX" is a no-no. + */ +bool is_filename_sane(const char *name, bool check_os_specific); + #endif /* FSTREE_H */ -- cgit v1.2.3