xbps_fetch_file: return proper error if connection failed,

fix SSP problem with fetchflags!

--HG--
extra : convert_revision : xtraeme%40gmail.com-20091107052101-ao6nqq8xrzb06tvr
This commit is contained in:
Juan RP 2009-11-07 06:21:01 +01:00
parent adbd3d727c
commit 79d3f446fe

View File

@ -196,7 +196,7 @@ xbps_fetch_file(const char *uri, const char *outputdir, const char *flags)
struct timeval tv[2];
ssize_t bytes_read, bytes_written;
off_t bytes_dld = -1;
char buf[4096], *filename, *destfile = NULL, fetchflags[8];
char buf[4096], *filename, *destfile = NULL;
int fd = -1, rv = 0;
bool restart = false;
@ -241,17 +241,11 @@ xbps_fetch_file(const char *uri, const char *outputdir, const char *flags)
goto out;
}
/*
* Set client flags.
*/
if (flags != NULL)
strcat(fetchflags, flags);
/*
* Establish connection to remote host.
*/
url->offset = st.st_size;
fio = fetchXGet(url, &url_st, fetchflags);
fio = fetchXGet(url, &url_st, flags);
#ifdef DEBUG
printf("st.st_size: %zd\n", (ssize_t)st.st_size);
printf("st.st_atime: %s\n", print_time(&st.st_atime));
@ -271,6 +265,11 @@ xbps_fetch_file(const char *uri, const char *outputdir, const char *flags)
#endif
if (fio == NULL) {
/* Local and remote size match, do nothing */
if (fetchLastErrCode != FETCH_OK) {
rv = fetchLastErrCode;
goto out;
}
if (url->length == 0)
goto out;
@ -350,11 +349,11 @@ xbps_fetch_file(const char *uri, const char *outputdir, const char *flags)
out:
if (fd != -1)
(void)close(fd);
if (fio)
if (fio != NULL)
fetchIO_close(fio);
if (url)
if (url != NULL)
fetchFreeURL(url);
if (destfile)
if (destfile != NULL)
free(destfile);
return rv;