From e75fcdd567c775a9bbb4551e519b6a48c5889ee0 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Tue, 15 Jan 2013 15:55:18 +0100 Subject: [PATCH] xbps_fetch_file: avoid copying from a NULL pointer. --- lib/download.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/download.c b/lib/download.c index ca15b4e8..d73de873 100644 --- a/lib/download.c +++ b/lib/download.c @@ -113,7 +113,9 @@ xbps_fetch_file(struct xbps_handle *xhp, const char *uri, const char *flags) if ((url = fetchParseURL(uri)) == NULL) return -1; - strlcpy(fetch_flags, flags, 7); + memset(&fetch_flags, 0, sizeof(fetch_flags)); + if (flags != NULL) + strlcpy(fetch_flags, flags, 7); /* * Get the filename specified in URI argument. */ @@ -144,7 +146,7 @@ xbps_fetch_file(struct xbps_handle *xhp, const char *uri, const char *flags) if (stat(filename, &st) == 0) { refetch = true; url->last_modified = st.st_mtime; - strcat(fetch_flags, "i"); + strlcat(fetch_flags, "i", sizeof(fetch_flags)); } else { if (errno != ENOENT) { rv = -1;