From 18c9c99848d5e611550ede85d03e7bc72cabd16b Mon Sep 17 00:00:00 2001 From: Lucas Holt Date: Tue, 28 Jan 2020 20:47:09 +0000 Subject: [PATCH] fix a buffer overflow in libfetch --- lib/libfetch/fetch.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index 19896e25a3d..2f2b097a950 100644 --- a/lib/libfetch/fetch.c +++ b/lib/libfetch/fetch.c @@ -329,6 +329,8 @@ fetch_pctdecode(char *dst, const char *src, size_t dlen) } if (dlen-- > 0) *dst++ = c; + else + return (NULL); } return (s); } @@ -376,11 +378,15 @@ fetchParseURL(const char *URL) if (p && *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;