[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] [PATCH] Check response existence on upgrade
From: |
Evgeny Grin |
Subject: |
Re: [libmicrohttpd] [PATCH] Check response existence on upgrade |
Date: |
Thu, 4 May 2017 23:36:23 +0300 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
Thanks! Applied.
--
Best Wishes,
Evgeny Grin
On 04.05.2017 22:58, José Bollo wrote:
> When a connection upgrade is requested and when the
> request sent an error reply, the response is most of
> the time already sent when the test on
> connection->response->upgrade_handler is made, leading
> to dereferencing NULL.
>
> Two possibilities exist:
>
> NULL == connection->response || NULL ==
> connection->response->upgrade_handler
>
> or
>
> NULL != connection->response && NULL ==
> connection->response->upgrade_handler
>
> The first is prefered because it is probably safer to close the
> connection in that case.
>
> Change-Id: Ie6e7fc165f7fe3635ade0952bb34a0b937d38716
> Signed-off-by: José Bollo <address@hidden>
> ---
> src/microhttpd/connection.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
> index 4753d6e..91a4492 100644
> --- a/src/microhttpd/connection.c
> +++ b/src/microhttpd/connection.c
> @@ -882,7 +882,7 @@ keepalive_possible (struct MHD_Connection
> *connection) #ifdef UPGRADE_SUPPORT
> if ( (MHD_str_equal_caseless_ (end,
> "upgrade")) &&
> - (NULL == connection->response->upgrade_handler) )
> + (NULL == connection->response || NULL ==
> connection->response->upgrade_handler) )
> return MHD_NO;
> #endif /* UPGRADE_SUPPORT */
>
>