Skip to content

Commit

Permalink
feat: check for malformed requests
Browse files Browse the repository at this point in the history
  • Loading branch information
lcsmuller committed Jun 10, 2023
1 parent dc8cb4d commit 9fdabcd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @{ */

typedef enum CCORDcode {
/** failure when creating request's payload */
CCORD_MALFORMED_PAYLOAD = -12,
/** couldn't enqueue worker thread (queue is full) */
CCORD_FULL_WORKER = -11,
/** couldn't perform action because resource is unavailable */
Expand Down
5 changes: 5 additions & 0 deletions src/discord-rest.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ discord_rest_run(struct discord_rest *rest,
static struct ccord_szbuf blank = { 0 };
body = ␣
}
else if (body->start && !body->size) {
logconf_error(&rest->conf, "(Internal error) Request body couldn't "
"be formed, please report it.");
return CCORD_MALFORMED_PAYLOAD;
}

/* build the endpoint string */
va_start(args, endpoint_fmt);
Expand Down

0 comments on commit 9fdabcd

Please sign in to comment.