X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fhttp.c;fp=src%2Fhttp.c;h=b2a03c87fd7a879f47a9e3a6506d04e221b63a56;hp=b0c782b94cbac70e4334b075e71035d04b09057a;hb=a300f1e47d12877b13cb661a9742de443232dc1a;hpb=72b2c58983a63849acede55b9fc619c76d61bdae diff --git a/src/http.c b/src/http.c index b0c782b9..b2a03c87 100644 --- a/src/http.c +++ b/src/http.c @@ -3697,8 +3697,7 @@ digest_authentication_encode (const char *au, const char *user, param_token name, value; - realm = opaque = nonce = qop = NULL; - algorithm = "MD5"; + realm = opaque = nonce = algorithm = qop = NULL; au += 6; /* skip over `Digest' */ while (extract_param (&au, &name, &value, ',')) @@ -3755,7 +3754,7 @@ digest_authentication_encode (const char *au, const char *user, dump_hash (a1buf, hash); - if (! strcmp (algorithm, "MD5-sess")) + if (algorithm && !strcmp (algorithm, "MD5-sess")) { /* A1BUF = H( H(user ":" realm ":" password) ":" nonce ":" cnonce ) */ snprintf (cnonce, sizeof (cnonce), "%08x", random_number(INT_MAX)); @@ -3855,6 +3854,13 @@ digest_authentication_encode (const char *au, const char *user, snprintf(res + res_len, res_size - res_len, ", algorithm=\"%s\"", algorithm); } } + + xfree_null (realm); + xfree_null (opaque); + xfree_null (nonce); + xfree_null (qop); + xfree_null (algorithm); + return res; } #endif /* ENABLE_DIGEST */