Skip to content

Commit

Permalink
Fix a crash bug with malformed URIs (Issue #418)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Jan 26, 2021
1 parent 6898d0a commit 19c582f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changes in HTMLDOC v1.9.12

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


Expand Down
4 changes: 3 additions & 1 deletion htmldoc/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ const char * /* O - File extension */
file_extension(const char *s) /* I - Filename or URL */
{
const char *extension; /* Pointer to directory separator */
char *bufptr; /* Pointer into buffer */
static char buf[1024]; /* Buffer for files with targets */


Expand Down Expand Up @@ -334,7 +335,8 @@ file_extension(const char *s) /* I - Filename or URL */

strlcpy(buf, extension, sizeof(buf));

*(char *)strchr(buf, '#') = '\0';
if ((bufptr = strchr(buf, '#')) != NULL)
*bufptr = '\0';

return (buf);
}
Expand Down

0 comments on commit 19c582f

Please sign in to comment.