]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mqtt: properly handle the message which exceeds maxsize
authorx2018 <xkernel.wang@foxmail.com>
Sun, 9 Nov 2025 11:19:13 +0000 (19:19 +0800)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 10 Nov 2025 08:07:27 +0000 (09:07 +0100)
We should goto fail as topic is allocated.

Follow-up to 92fd791

Closes #19417

lib/mqtt.c

index bac319e63a4c4ab65db07f85ce18d5ee16979085..713e4aa02cd6fe1bb5ef234a46d8287a01e58eda 100644 (file)
@@ -613,8 +613,10 @@ 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;
+  if(MAX_MQTT_MESSAGE_SIZE - remaininglength - 1 < encodelen) {
+    result = CURLE_TOO_LARGE;
+    goto fail;
+  }
 
   /* add the control byte and the encoded remaining length */
   pkt = malloc(remaininglength + 1 + encodelen);