From c60fe0c6f61d5ed1dfd047387dc084ccea8e5474 Mon Sep 17 00:00:00 2001 From: Alexander Alashkin Date: Mon, 3 Apr 2017 10:14:16 +0100 Subject: [PATCH] Fix crash in multipart handling Close cesanta/dev#6974 PUBLISHED_FROM=4d4e4a46eceba10aec8dacb7f8f58bd078c92307 --- mongoose.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mongoose.c b/mongoose.c index d0dcf8b8..b45823bf 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5879,6 +5879,12 @@ static int mg_http_multipart_wait_for_boundary(struct mg_connection *c) { struct mbuf *io = &c->recv_mbuf; struct mg_http_proto_data *pd = mg_http_get_proto_data(c); + if (pd->mp_stream.boundary == NULL) { + pd->mp_stream.state = MPS_FINALIZE; + DBG(("Invalid request: boundary not initilaized")); + return 0; + } + if ((int) io->len < pd->mp_stream.boundary_len + 2) { return 0; }