diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2012-11-05 10:45:37 +0000 | 
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2012-11-05 10:45:37 +0000 | 
| commit | 6a09724dca36958ad5ee581f5133ea100d0f6de1 (patch) | |
| tree | 2e64511427accfea07590b84e32805d900daa52a | |
| parent | e987534d6f2acffcba8059a8a36d5b357c99e8af (diff) | |
Notes
| -rw-r--r-- | lib/libfetch/Makefile | 4 | ||||
| -rw-r--r-- | lib/libfetch/common.c | 30 | ||||
| -rw-r--r-- | lib/libfetch/fetch.3 | 4 | ||||
| -rw-r--r-- | lib/libfetch/http.c | 12 | 
4 files changed, 28 insertions, 22 deletions
| diff --git a/lib/libfetch/Makefile b/lib/libfetch/Makefile index 7b29aa2df5e5..085aba2c6cb4 100644 --- a/lib/libfetch/Makefile +++ b/lib/libfetch/Makefile @@ -16,8 +16,8 @@ CFLAGS+=	-DINET6  .if ${MK_OPENSSL} != "no"  CFLAGS+=	-DWITH_SSL -DPADD=		${LIBSSL} ${LIBCRYPTO} ${LIBMD} -LDADD=		-lssl -lcrypto -lmd +DPADD=		${LIBSSL} ${LIBCRYPTO} +LDADD=		-lssl -lcrypto  .else  DPADD=		${LIBMD}  LDADD=		-lmd diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index e55459c54a3a..967a708a27c9 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -458,11 +458,9 @@ fetch_read(conn_t *conn, char *buf, size_t len)  	struct timeval now, timeout, delta;  	fd_set readfds;  	ssize_t rlen, total; -	int r;  	char *start; -	if (fetchTimeout) { -		FD_ZERO(&readfds); +	if (fetchTimeout > 0) {  		gettimeofday(&timeout, NULL);  		timeout.tv_sec += fetchTimeout;  	} @@ -526,23 +524,21 @@ fetch_read(conn_t *conn, char *buf, size_t len)  			return (-1);  		}  		// assert(rlen == FETCH_READ_WAIT); -		while (fetchTimeout && !FD_ISSET(conn->sd, &readfds)) { +		FD_ZERO(&readfds); +		while (!FD_ISSET(conn->sd, &readfds)) {  			FD_SET(conn->sd, &readfds); -			gettimeofday(&now, NULL); -			delta.tv_sec = timeout.tv_sec - now.tv_sec; -			delta.tv_usec = timeout.tv_usec - now.tv_usec; -			if (delta.tv_usec < 0) { -				delta.tv_usec += 1000000; -				delta.tv_sec--; -			} -			if (delta.tv_sec < 0) { -				errno = ETIMEDOUT; -				fetch_syserr(); -				return (-1); +			if (fetchTimeout > 0) { +				gettimeofday(&now, NULL); +				if (!timercmp(&timeout, &now, >)) { +					errno = ETIMEDOUT; +					fetch_syserr(); +					return (-1); +				} +				timersub(&timeout, &now, &delta);  			}  			errno = 0; -			r = select(conn->sd + 1, &readfds, NULL, NULL, &delta); -			if (r == -1) { +			if (select(conn->sd + 1, &readfds, NULL, NULL, +				fetchTimeout > 0 ? &delta : NULL) < 0) {  				if (errno == EINTR) {  					if (fetchRestartCalls)  						continue; diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3 index 1d60b4df5f12..bdca63e68c94 100644 --- a/lib/libfetch/fetch.3 +++ b/lib/libfetch/fetch.3 @@ -25,7 +25,7 @@  .\"  .\" $FreeBSD$  .\" -.Dd January 26, 2010 +.Dd September 27, 2011  .Dt FETCH 3  .Os  .Sh NAME @@ -365,7 +365,7 @@ If the  (if-modified-since) flag is specified, and  the  .Va ims_time -field is set in  +field is set in  .Vt "struct url" ,  then  .Fn fetchXGetHTTP diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index d388c7e08e7a..00dd887cfce1 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -76,7 +76,15 @@ __FBSDID("$FreeBSD$");  #include <string.h>  #include <time.h>  #include <unistd.h> + +#ifdef WITH_SSL +#include <openssl/md5.h> +#define MD5Init(c) MD5_Init(c) +#define MD5Update(c, data, len) MD5_Update(c, data, len) +#define MD5Final(md, c) MD5_Final(md, c) +#else  #include <md5.h> +#endif  #include <netinet/in.h>  #include <netinet/tcp.h> @@ -1793,7 +1801,9 @@ http_request(struct url *URL, const char *op, struct url_stat *us,  					DEBUG(fprintf(stderr, "failed to parse new URL\n"));  					goto ouch;  				} -				if (!*new->user && !*new->pwd) { + +				/* Only copy credentials if the host matches */ +				if (!strcmp(new->host, url->host) && !*new->user && !*new->pwd) {  					strcpy(new->user, url->user);  					strcpy(new->pwd, url->pwd);  				} | 
