From 57675c7dfcfe384d9d937ee1e311b95cfdb7bcc2 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Tue, 28 Jan 2020 20:03:56 +0100 Subject: [PATCH] lib/fetch: fix CVE-2020-7450 https://www.freebsd.org/security/advisories/FreeBSD-SA-20:01.libfetch.asc --- lib/fetch/fetch.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/fetch/fetch.c b/lib/fetch/fetch.c index d0cce7b8..feaf768d 100644 --- a/lib/fetch/fetch.c +++ b/lib/fetch/fetch.c @@ -331,6 +331,8 @@ fetch_pctdecode(char *dst, const char *src, size_t dlen) } if (dlen-- > 0) *dst++ = c; + else + return (NULL); } return (s); } @@ -481,10 +483,14 @@ find_user: if (p != NULL && *p == '@') { /* username */ q = fetch_pctdecode(u->user, URL, URL_USERLEN); + if (q == NULL) + goto ouch; /* password */ - if (*q == ':') + if (*q == ':') { q = fetch_pctdecode(u->pwd, q + 1, URL_PWDLEN); - + if (q == NULL) + goto ouch; + } p++; } else { p = URL;