Skip to content

Commit f1f4d29

Browse files
committed
feat: check for malformed requests
1 parent daef451 commit f1f4d29

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Diff for: core/error.h

+2
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 */

Diff for: src/discord-rest.c

+5
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)