lib: fix coverity CID 1574979

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2023-12-30 14:48:15 +00:00
parent 913892e2ad
commit b28cd405c8
2 changed files with 7 additions and 0 deletions

View file

@ -111,6 +111,11 @@ enum mgmt_msg_rsched mgmt_msg_read(struct mgmt_msg_state *ms, int fd,
* therefor the stream is too small to fit the message..
* Resize the stream to fit.
*/
if (mhdr->len > MGMT_MSG_MAX_MSG_ALLOC_LEN) {
MGMT_MSG_ERR(ms, "corrupt msg len rcvd %u",
mhdr->len);
return MSR_DISCONNECT;
}
news = stream_new(mhdr->len);
stream_put(news, mhdr, left);
stream_set_endp(news, left);

View file

@ -24,6 +24,8 @@ DECLARE_MTYPE(MSG_CONN);
#define MGMT_MSG_VERSION_PROTOBUF 0
#define MGMT_MSG_VERSION_NATIVE 1
/* The absolute maximum message size (16MB) */
#define MGMT_MSG_MAX_MSG_ALLOC_LEN (16 * 1024 * 1024)
struct mgmt_msg_state {
struct stream *ins;