mqtt: better handling of TCP disconnect mid-message

Reported-by: Jenny Heino
Bug: https://hackerone.com/reports/1521610
Closes #8644
This commit is contained in:
Daniel Stenberg 2022-03-29 08:43:13 +02:00
parent 301bd97965
commit 87da3e845b
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -732,8 +732,14 @@ static CURLcode mqtt_doing(struct Curl_easy *data, bool *done)
case MQTT_FIRST:
/* Read the initial byte only */
result = Curl_read(data, sockfd, (char *)&mq->firstbyte, 1, &nread);
if(!nread)
if(result)
break;
else if(!nread) {
failf(data, "Connection disconnected");
*done = TRUE;
result = CURLE_RECV_ERROR;
break;
}
Curl_debug(data, CURLINFO_HEADER_IN, (char *)&mq->firstbyte, 1);
/* remember the first byte */
mq->npacket = 0;