mqtt: better too-big-message-check

Reported-by: gudyuu on hackerone
Reviewed-by: Daniel Gustafsson
Bug: https://hackerone.com/reports/3508500
Closes #20281
This commit is contained in:
Daniel Stenberg 2026-01-13 08:20:12 +01:00
parent 4b566d8310
commit dac98ccfa2
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -562,7 +562,7 @@ 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) {
if(remaininglength > (MAX_MQTT_MESSAGE_SIZE - encodelen - 1)) {
result = CURLE_TOO_LARGE;
goto fail;
}