mqtt: free any leftover when done
Oss-fuzz found an issue when the "sendleftovers" pointer could leak memory. Fix this by always freeing it (if still assigned) in the done function. Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43515 Closes #8274
This commit is contained in:
Родитель
8188ca91eb
Коммит
84853d94f2
16
lib/mqtt.c
16
lib/mqtt.c
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2020 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2020 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2019, Björn Stenberg, <bjorn@haxx.se>
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
|
@ -60,6 +60,8 @@
|
|||
*/
|
||||
|
||||
static CURLcode mqtt_do(struct Curl_easy *data, bool *done);
|
||||
static CURLcode mqtt_done(struct Curl_easy *data,
|
||||
CURLcode status, bool premature);
|
||||
static CURLcode mqtt_doing(struct Curl_easy *data, bool *done);
|
||||
static int mqtt_getsock(struct Curl_easy *data, struct connectdata *conn,
|
||||
curl_socket_t *sock);
|
||||
|
@ -74,7 +76,7 @@ const struct Curl_handler Curl_handler_mqtt = {
|
|||
"MQTT", /* scheme */
|
||||
mqtt_setup_conn, /* setup_connection */
|
||||
mqtt_do, /* do_it */
|
||||
ZERO_NULL, /* done */
|
||||
mqtt_done, /* done */
|
||||
ZERO_NULL, /* do_more */
|
||||
ZERO_NULL, /* connect_it */
|
||||
ZERO_NULL, /* connecting */
|
||||
|
@ -692,6 +694,16 @@ static CURLcode mqtt_do(struct Curl_easy *data, bool *done)
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static CURLcode mqtt_done(struct Curl_easy *data,
|
||||
CURLcode status, bool premature)
|
||||
{
|
||||
struct MQTT *mq = data->req.p.mqtt;
|
||||
(void)status;
|
||||
(void)premature;
|
||||
Curl_safefree(mq->sendleftovers);
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static CURLcode mqtt_doing(struct Curl_easy *data, bool *done)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче