Skip to content

Commit

Permalink
Prevent user from setting wwwroot to NULL (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
g-rden authored Mar 5, 2024
1 parent 2055a5d commit 2417ddf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion darkhttpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,9 @@ static void parse_commandline(const int argc, char *argv[]) {
wwwroot = xstrdup(argv[1]);
/* Strip ending slash. */
len = strlen(wwwroot);
if (len > 0)
if (len == 0)
errx(1, "/path/to/wwwroot cannot be empty");
if (len > 1)
if (wwwroot[len - 1] == '/')
wwwroot[len - 1] = '\0';

Expand Down

0 comments on commit 2417ddf

Please sign in to comment.