xbps_fetch_file: avoid copying from a NULL pointer.

This commit is contained in:
Juan RP 2013-01-15 15:55:18 +01:00
parent 3139f822da
commit e75fcdd567

View File

@ -113,6 +113,8 @@ xbps_fetch_file(struct xbps_handle *xhp, const char *uri, const char *flags)
if ((url = fetchParseURL(uri)) == NULL) if ((url = fetchParseURL(uri)) == NULL)
return -1; return -1;
memset(&fetch_flags, 0, sizeof(fetch_flags));
if (flags != NULL)
strlcpy(fetch_flags, flags, 7); strlcpy(fetch_flags, flags, 7);
/* /*
* Get the filename specified in URI argument. * 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) { if (stat(filename, &st) == 0) {
refetch = true; refetch = true;
url->last_modified = st.st_mtime; url->last_modified = st.st_mtime;
strcat(fetch_flags, "i"); strlcat(fetch_flags, "i", sizeof(fetch_flags));
} else { } else {
if (errno != ENOENT) { if (errno != ENOENT) {
rv = -1; rv = -1;