From 89e8fb58bece299a29260d145a0381928234a6c0 Mon Sep 17 00:00:00 2001 From: Rairii <2650838+Wack0@users.noreply.github.com> Date: Sun, 4 Aug 2024 10:55:50 +0100 Subject: [PATCH] arcfw(cdfs): when opening file without extension also check for filename with dot suffix NT 3.51 PMZ has setupldr actually named "setupldr.", so this is required there. Fixes #33 . --- arcgrackle/source/lib9660.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/arcgrackle/source/lib9660.c b/arcgrackle/source/lib9660.c index 9481c4e..dd2be10 100644 --- a/arcgrackle/source/lib9660.c +++ b/arcgrackle/source/lib9660.c @@ -196,11 +196,14 @@ static l9660_status openat_raw(l9660_file *child, l9660_dir *parent, const char const char *seg = name; name = strchrnul(name, '\\'); size_t seglen = (size_t)name - (size_t)seg; + bool check_also_for_dot = false; if (*name) name++; + else if (strchr(seg, '.') == NULL) check_also_for_dot = true; /* ISO9660 stores '.' as '\0' */ - if (seglen == 1 && *seg == '.') + if (seglen == 1 && *seg == '.') { seg = "\0"; + } /* ISO9660 stores ".." as '\1' */ if (seglen == 2 && seg[0] == '.' && seg[1] == '.') { @@ -221,16 +224,23 @@ static l9660_status openat_raw(l9660_file *child, l9660_dir *parent, const char #endif /* wrong length */ - if (seglen > dent->name_len) + if (seglen > dent->name_len) { continue; + } /* check name */ if (strnicmp(seg, dent->name, seglen) != 0) continue; /* check for a revision tag */ - if (dent->name_len > seglen && dent->name[seglen] != ';') - continue; + if (dent->name_len > seglen && dent->name[seglen] != ';') { + if (!check_also_for_dot) continue; + if (dent->name_len > (seglen + 1)) { + if (dent->name[seglen] != '.') continue; + if (dent->name[seglen + 1] != ';') continue; + } + else continue; + } /* all tests pass */ break;