Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ void uh_interpreter_add(const char *ext, const char *path)
in = calloc_a(sizeof(*in),
&new_ext, strlen(ext) + 1,
&new_path, strlen(path) + 1);
if (!in) {
fprintf(stderr,
"uhttpd: OOM while adding CGI interpreter (%s -> %s)\n",
ext, path);
return;
}

in->ext = strcpy(new_ext, ext);
in->path = strcpy(new_path, path);
Expand Down
10 changes: 9 additions & 1 deletion file.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ uh_free_pending_request(struct client *cl)
free(dr);
}

static int field_len(const char *ptr)
static size_t field_len(const char *ptr)
{
if (!ptr)
return 0;
Expand Down Expand Up @@ -821,6 +821,10 @@ uh_defer_script(struct client *cl, struct dispatch_handler *d, char *url, struct
#undef _field
#define _field(_name) &_##_name, field_len(pi->_name),
dr = calloc_a(sizeof(*dr), &_url, strlen(url) + 1, path_info_fields NULL);
if (!dr) {
uh_client_error(cl, 500, "Internal Server Error", "Out of memory");
return;
}

memcpy(&dr->pi, pi, sizeof(*pi));
dr->path = true;
Expand All @@ -831,6 +835,10 @@ uh_defer_script(struct client *cl, struct dispatch_handler *d, char *url, struct
path_info_fields
} else {
dr = calloc_a(sizeof(*dr), &_url, strlen(url) + 1, NULL);
if (!dr) {
uh_client_error(cl, 500, "Internal Server Error", "Out of memory");
return;
}
}

cl->dispatch.req_data = dr;
Expand Down