Skip to content

Commit 9fdabcd

Browse files
committed
feat: check for malformed requests
1 parent dc8cb4d commit 9fdabcd

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

core/error.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @{ */
99

1010
typedef enum CCORDcode {
11+
/** failure when creating request's payload */
12+
CCORD_MALFORMED_PAYLOAD = -12,
1113
/** couldn't enqueue worker thread (queue is full) */
1214
CCORD_FULL_WORKER = -11,
1315
/** couldn't perform action because resource is unavailable */

src/discord-rest.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ discord_rest_run(struct discord_rest *rest,
120120
static struct ccord_szbuf blank = { 0 };
121121
body = ␣
122122
}
123+
else if (body->start && !body->size) {
124+
logconf_error(&rest->conf, "(Internal error) Request body couldn't "
125+
"be formed, please report it.");
126+
return CCORD_MALFORMED_PAYLOAD;
127+
}
123128

124129
/* build the endpoint string */
125130
va_start(args, endpoint_fmt);

0 commit comments

Comments
 (0)