]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Handle empty response buf in process_http_response()
authorDavid Woodhouse <dwmw2@infradead.org>
Mon, 12 Apr 2021 22:05:07 +0000 (23:05 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Tue, 13 Apr 2021 08:55:10 +0000 (09:55 +0100)
If there is no body and the 'body' buf has never had any data in it, then
body->data can be NULL. So don't dereference it when trying to ensure a
NUL at the end.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
http.c

diff --git a/http.c b/http.c
index bb82a22b801f77cbc255e055ed2bfa446a02803a..1fd1e5b9820b4ef56993558ec7f44e7a003e5837 100644 (file)
--- a/http.c
+++ b/http.c
@@ -773,7 +773,8 @@ int process_http_response(struct openconnect_info *vpninfo, int connect,
                }
        }
 
-       body->data[body->pos] = 0;
+       if (body && body->data)
+               body->data[body->pos] = 0;
        ret = result;
 
        if (closeconn || vpninfo->no_http_keepalive) {