mirror of
https://github.com/curl/curl.git
synced 2026-04-15 01:31:41 +03:00
mqtt: reject overly big messages
Reported-by: Jiyong Yang Closes #19415
This commit is contained in:
parent
a002c50510
commit
92fd791f31
1 changed files with 4 additions and 0 deletions
|
|
@ -582,6 +582,8 @@ fail:
|
|||
return result;
|
||||
}
|
||||
|
||||
#define MAX_MQTT_MESSAGE_SIZE 0xFFFFFFF
|
||||
|
||||
static CURLcode mqtt_publish(struct Curl_easy *data)
|
||||
{
|
||||
CURLcode result;
|
||||
|
|
@ -611,6 +613,8 @@ static CURLcode mqtt_publish(struct Curl_easy *data)
|
|||
|
||||
remaininglength = payloadlen + 2 + topiclen;
|
||||
encodelen = mqtt_encode_len(encodedbytes, remaininglength);
|
||||
if(MAX_MQTT_MESSAGE_SIZE - remaininglength - 1 < encodelen)
|
||||
return CURLE_TOO_LARGE;
|
||||
|
||||
/* add the control byte and the encoded remaining length */
|
||||
pkt = malloc(remaininglength + 1 + encodelen);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue