From: Alexander Couzens Date: Sun, 11 Jun 2017 11:01:06 +0000 (+0200) Subject: uclient-fetch: read_data_cb: fix a potential buffer overflow X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=83ce236dab867842cdba88a57db50aae0fd9a4ce;p=project%2Fuclient.git uclient-fetch: read_data_cb: fix a potential buffer overflow When a backend->read() is not implement or returns -1, This -1 is interpreted as unsigned int resulting in an access far behind the buffer. Signed-off-by: Alexander Couzens --- diff --git a/uclient-fetch.c b/uclient-fetch.c index d9582f5..dff144b 100644 --- a/uclient-fetch.c +++ b/uclient-fetch.c @@ -262,7 +262,7 @@ static void read_data_cb(struct uclient *cl) while (1) { len = uclient_read(cl, buf, sizeof(buf)); - if (!len) + if (len <= 0) return; out_bytes += len;