Skip to content

Commit

Permalink
Fix crash bug with data: URIs (Issue #410)
Browse files Browse the repository at this point in the history
Fix URL regression caused by Coverity changes (Issue #409)
  • Loading branch information
michaelrsweet committed Jan 23, 2021
1 parent ae8fb53 commit 008861d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
@@ -1,3 +1,9 @@
# Changes in HTMLDOC v1.9.12

- Fixed a crash bug with "data:" URIs and EPUB output (Issue #410)
- Fixed some issues reported by Coverity.


# Changes in HTMLDOC v1.9.11

- Added high-resolution desktop icons for Linux.
Expand Down
18 changes: 10 additions & 8 deletions htmldoc/file.c
Expand Up @@ -622,11 +622,13 @@ file_find(const char *path, /* I - Path "dir;dir;dir" */
*/

for (i = 0; i < (int)web_files; i ++)
{
if (strcmp(s, web_cache[i].name) == 0)
{
DEBUG_printf(("file_find: Returning cache file \"%s\"!\n", s));
return (web_cache[i].name);
}
}

DEBUG_printf(("file_find: \"%s\" not in web cache of %d files...\n", s, (int)web_files));

Expand All @@ -635,11 +637,14 @@ file_find(const char *path, /* I - Path "dir;dir;dir" */
*/

if (strchr(s, '%') == NULL)
{
strlcpy(basename, s, sizeof(basename));
}
else
{
for (sptr = s, temp = basename;
*sptr && temp < (basename + sizeof(basename) - 1);)
{
if (*sptr == '%' && isxdigit(sptr[1]) && isxdigit(sptr[2]))
{
/*
Expand All @@ -662,6 +667,7 @@ file_find(const char *path, /* I - Path "dir;dir;dir" */
}
else
*temp++ = *sptr++;
}

*temp = '\0';
}
Expand Down Expand Up @@ -725,13 +731,7 @@ file_find(const char *path, /* I - Path "dir;dir;dir" */
}
}

if (file_find_check(s))
{
strlcpy(filename, s, sizeof(filename));
return (filename);
}
else
return (NULL);
return (file_find_check(s));
}


Expand Down Expand Up @@ -922,7 +922,9 @@ file_localize(const char *filename, /* I - Filename */
const char * /* O - Method string ("http", "ftp", etc.) */
file_method(const char *s) /* I - Filename or URL */
{
if (strncmp(s, "http:", 5) == 0)
if (strncmp(s, "data:", 5) == 0)
return ("data");
else if (strncmp(s, "http:", 5) == 0)
return ("http");
else if (strncmp(s, "https:", 6) == 0)
return ("https");
Expand Down

0 comments on commit 008861d

Please sign in to comment.