From c8d1a885f84cb26035c0f2d6827e74d1338c7a16 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 8 Aug 2016 05:32:20 +0200 Subject: webfs: avoid retry loops when we got a bad key in factotum --- sys/src/cmd/webfs/http.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'sys/src/cmd/webfs') diff --git a/sys/src/cmd/webfs/http.c b/sys/src/cmd/webfs/http.c index be800c4a2..01def74b5 100644 --- a/sys/src/cmd/webfs/http.c +++ b/sys/src/cmd/webfs/http.c @@ -518,7 +518,7 @@ catch(void *, char *msg) void http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost) { - int i, l, n, try, pid, fd, cfd, needlength, chunked, retry, nobody; + int i, l, n, try, pid, fd, cfd, needlength, chunked, retry, nobody, badauth; char *s, *x, buf[8192+2], status[256], method[16], *host; vlong length, offset; Url ru, tu, *nu; @@ -560,6 +560,7 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost) pid = 0; host = nil; needlength = 0; + badauth = 0; for(try = 0; try < 12; try++){ strcpy(status, "0 No status"); if(u == nil || (strcmp(u->scheme, "http") && strcmp(u->scheme, "https"))){ @@ -864,8 +865,11 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost) u = nu; if(0){ case 401: /* Unauthorized */ - if(x = lookkey(shdr, "Authorization")) + if(x = lookkey(shdr, "Authorization")){ flushauth(nil, x); + if(badauth++) + goto Error; + } if(hauthenticate(u, &ru, method, "WWW-Authenticate", rhdr) < 0){ Autherror: h->cancel = 1; @@ -879,8 +883,11 @@ http(char *m, Url *u, Key *shdr, Buq *qbody, Buq *qpost) case 407: /* Proxy Auth */ if(proxy == nil) goto Error; - if(x = lookkey(shdr, "Proxy-Authorization")) + if(x = lookkey(shdr, "Proxy-Authorization")){ flushauth(proxy, x); + if(badauth++) + goto Error; + } if(hauthenticate(proxy, proxy, method, "Proxy-Authenticate", rhdr) < 0) goto Autherror; } -- cgit v1.2.3