fix: discord_create_message() payload does not need a hard-coded size limit
@@ -298,8 +298,8 @@ discord_create_message(
if (params->message_reference)
A[4] = (void *)params->message_reference;
- char payload[MAX_PAYLOAD_LEN];
- json_inject(payload, sizeof(payload),
+ char *payload=NULL;
+ size_t ret = json_ainject(&payload,
"(content):s"
"(nonce):s"
"(tts):b"
@@ -319,7 +319,12 @@ discord_create_message(
&discord_message_reference_to_json, params->message_reference,
A, sizeof(A));
- struct sized_buffer req_body = {payload, strlen(payload)};
+ if (!payload) {
+ log_error("Couldn't create JSON Payload");
+ return;
+ }
+
+ struct sized_buffer req_body = {payload, ret};
discord_adapter_run(
&client->adapter,
@@ -327,6 +332,8 @@ discord_create_message(
&req_body,
HTTP_POST,
"/channels/%"PRIu64"/messages", channel_id);
+
+ free(payload);
}
else
{ // content-type is multipart/form-data
