Fix: add check for hidden files in get_ext()

This commit is contained in:
Nikita Ivanov 2022-05-24 00:36:02 +05:00
parent 1f460e2de1
commit 7f0ea955c4
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133

13
ctpv.c
View File

@ -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];