Skip to content

Commit

Permalink
modified: src/http.c
Browse files Browse the repository at this point in the history
  • Loading branch information
jvo203 committed Sep 5, 2022
1 parent ee35d7a commit df864bc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,11 @@ static enum MHD_Result serve_file(struct MHD_Connection *connection, const char
fd = -1; /* Do not allow usage of parent directories. */
else
{
#ifdef SHARE
snprintf(path, sizeof(path), SHARE "/htdocs%s", url);
#else
snprintf(path, sizeof(path), "htdocs%s", url);
#endif
fd = open(path, O_RDONLY);
}

Expand Down Expand Up @@ -2351,9 +2355,14 @@ void create_root_path(const char *root)
if (root == NULL)
return;

// prepend root by "htdocs/"
// prepend root by "htdocs/"
#ifdef SHARE
char *link = malloc(strlen(root) + strlen(SHARE "/htdocs") + 1);
sprintf(link, SHARE "/htdocs%s", root); // '/' is added by the server
#else
char *link = malloc(strlen(root) + strlen("htdocs") + 1);
sprintf(link, "htdocs%s", root); // '/' is added by the server
#endif

// remove the last slash
if (link[strlen(link) - 1] == '/')
Expand Down

0 comments on commit df864bc

Please sign in to comment.