Message ID | 20200409113423.9210-1-toertel@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | mongoose: Fix CID 292194 logically dead code | expand |
Hi Mark, On 09.04.20 13:34, Mark Jonas wrote: > The if- and else-if-clause already cover the complete value range of > 'boundary'. Thus, the original else cannot be reached. Because the > original else-if-clause triggers on the negation of the if-clause it can > be replaced with a simple else. > > Signed-off-by: Mark Jonas <toertel@gmail.com> > --- > mongoose/mongoose.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/mongoose/mongoose.c b/mongoose/mongoose.c > index 2d3e1d2..2f2c4b2 100644 > --- a/mongoose/mongoose.c > +++ b/mongoose/mongoose.c > @@ -6827,7 +6827,7 @@ static int mg_http_multipart_continue_wait_for_chunk(struct mg_connection *c) { > mbuf_remove(io, consumed); > } > return 0; > - } else if (boundary != NULL) { > + } else { > size_t data_len = ((size_t)(boundary - io->buf) - 4); > size_t consumed = mg_http_multipart_call_handler(c, MG_EV_HTTP_PART_DATA, > io->buf, data_len); > @@ -6839,8 +6839,6 @@ static int mg_http_multipart_continue_wait_for_chunk(struct mg_connection *c) { > } else { > return 0; > } > - } else { > - return 0; > } > } > > This is true, but code is taken as it is from mongoose project. I will merge this in anycase for SWUpdate, but I think about if fixes for mongoose should not be also sent to the Mongoose project. Acked-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano
Hi Stefano, > This is true, but code is taken as it is from mongoose project. I will > merge this in anycase for SWUpdate, but I think about if fixes for > mongoose should not be also sent to the Mongoose project. Good idea. I created a pull request. https://github.com/cesanta/mongoose/pull/1112 Greetings, Mark
diff --git a/mongoose/mongoose.c b/mongoose/mongoose.c index 2d3e1d2..2f2c4b2 100644 --- a/mongoose/mongoose.c +++ b/mongoose/mongoose.c @@ -6827,7 +6827,7 @@ static int mg_http_multipart_continue_wait_for_chunk(struct mg_connection *c) { mbuf_remove(io, consumed); } return 0; - } else if (boundary != NULL) { + } else { size_t data_len = ((size_t)(boundary - io->buf) - 4); size_t consumed = mg_http_multipart_call_handler(c, MG_EV_HTTP_PART_DATA, io->buf, data_len); @@ -6839,8 +6839,6 @@ static int mg_http_multipart_continue_wait_for_chunk(struct mg_connection *c) { } else { return 0; } - } else { - return 0; } }
The if- and else-if-clause already cover the complete value range of 'boundary'. Thus, the original else cannot be reached. Because the original else-if-clause triggers on the negation of the if-clause it can be replaced with a simple else. Signed-off-by: Mark Jonas <toertel@gmail.com> --- mongoose/mongoose.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)