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