From 358073d713deb16460ae633d5a48a8e48180369f Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 14 Feb 2024 09:21:30 +0100 Subject: Fix win32 filename sanitation for cases were we have clashes We fix filenames containing components like COM1 or PRN by appending an underscore ('_'). A squashfs archive may contain files that already have such a modifed name (e.g. COM1_) which would now potentially clash. This is fixed by matching any number of trailing '_' characters for the bad name and adding another one. So all existing names that start with an illegal prefix and have any number of underscores, will always have an additional one appended. Signed-off-by: David Oberhollenzer --- tests/libutil/fix_win32_filename.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/libutil/fix_win32_filename.c b/tests/libutil/fix_win32_filename.c index a4f71e8..e8932d6 100644 --- a/tests/libutil/fix_win32_filename.c +++ b/tests/libutil/fix_win32_filename.c @@ -22,6 +22,10 @@ static const struct { { "foo/bar/test.LPT1/bla", "foo/bar/test.LPT1_/bla" }, { "C:\\/foo/COM1.bla/bar", "C\xEF\x80\xBA\xEF\x81\x9c/foo/COM1_.bla/bar" }, + { "com1", "com1_" }, + { "COM1_", "COM1__" }, + { "COM1__", "COM1___" }, + { "COM1___", "COM1____" }, }; int main(int argc, char **argv) -- cgit v1.2.3