autoupdater: uclient: fix nullpointer dereference on invalid URL (#183)

Previously supplying an invalid url for download would result in
uclient_new returning NULL and crash the autoupdater as soon as
cl->priv is accessed.

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
This commit is contained in:
Tobias 2018-02-19 17:10:44 +01:00 committed by Matthias Schiffer
parent 7abd688e6a
commit c802276581
2 changed files with 7 additions and 2 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=autoupdater
PKG_VERSION:=3
PKG_VERSION:=4
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

View File

@ -161,6 +161,9 @@ int get_url(const char *url, void (*read_cb)(struct uclient *cl), void *cb_data,
};
struct uclient *cl = uclient_new(url, NULL, &cb);
if (!cl)
goto err;
cl->priv = &d;
if (uclient_set_timeout(cl, TIMEOUT_MSEC))
goto err;
@ -183,6 +186,8 @@ int get_url(const char *url, void (*read_cb)(struct uclient *cl), void *cb_data,
return d.err_code;
err:
uclient_free(cl);
if (cl)
uclient_free(cl);
return UCLIENT_ERROR_CONNECT;
}