From 7f0ea955c4ec7465ed6b0a0a8f131511e446c1f5 Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Tue, 24 May 2022 00:36:02 +0500 Subject: [PATCH] Fix: add check for hidden files in get_ext() --- ctpv.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ctpv.c b/ctpv.c index e4e1506..20ff61b 100644 --- a/ctpv.c +++ b/ctpv.c @@ -59,12 +59,15 @@ static const char *get_mimetype(char const *path) static const char *get_ext(char const *path) { - const char *dot = strrchr(path, '.'); - if (!dot) - return NULL; + const char *base; - const char *slash = strrchr(path, '/'); - if (slash && dot < slash) + if ((base = strrchr(path, '/'))) + base += sizeof(*base); + else + base = path; + + const char *dot = strrchr(path, '.'); + if (!dot || dot == base) return NULL; return &dot[1];