Deleted Added
full compact
28c28
< * $FreeBSD: head/lib/libfetch/http.c 61896 2000-06-21 09:49:51Z des $
---
> * $FreeBSD: head/lib/libfetch/http.c 62811 2000-07-08 08:08:58Z des $
278,279c278,279
< int len, lu, lp;
< char *str, *s;
---
> int len, lup;
> char *uandp, *str = NULL;
281,296c281,293
< lu = strlen(usr);
< lp = strlen(pwd);
<
< len = (lu * 4 + 2) / 3 /* user name, round up */
< + 1 /* colon */
< + (lp * 4 + 2) / 3 /* password, round up */
< + 1; /* null */
<
< if ((s = str = (char *)malloc(len)) == NULL)
< return NULL;
<
< s += _http_base64(s, usr, lu);
< *s++ = ':';
< s += _http_base64(s, pwd, lp);
< *s = 0;
<
---
> lup = strlen(usr) + 1 + strlen(pwd);/* length of "usr:pwd" */
> uandp = (char*)malloc(lup + 1);
> if (uandp) {
> len = ((lup + 2) / 3) * 4; /* length of base64 encoded "usr:pwd" incl. padding */
> str = (char*)malloc(len + 1);
> if (str) {
> strcpy(uandp, usr);
> strcat(uandp, ":");
> strcat(uandp, pwd);
> _http_base64(str, uandp, lup);
> }
> free(uandp);
> }
468a466,494
> if (p = getenv("HTTP_PROXY_AUTH")) {
> char *auth;
>
> /* skip leading "basic:*:", if present */
> if (strncmp(p, "basic:*:", 6 + 2) == 0)
> p += 6 + 2;
> auth = strchr(p, ':');
> if (auth != NULL) {
> int len = auth - p;
> char *user;
> char *auth_str;
>
> if ((user = (char*)malloc(len + 1)) == NULL) {
> free(auth);
> return 999; /* XXX wrong */
> }
> strncpy(user, p, len);
> user[len] = 0;
> auth++;
> auth_str = _http_auth(user, auth);
> free(user);
> if (auth_str == NULL)
> return 999; /* XXX wrong */
> _http_cmd(f, "Proxy-Authorization: Basic %s" ENDL, auth_str);
> free(auth_str);
> } else {
> return 999; /* XXX wrong */
> }
> }