]> sjero.net Git - wget/commitdiff
Fix some memory leaks a problem introduced with the last commit
authorGiuseppe Scrivano <gscrivano@gnu.org>
Fri, 12 Jul 2013 21:44:21 +0000 (23:44 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Sat, 13 Jul 2013 14:25:43 +0000 (16:25 +0200)
src/ChangeLog
src/http.c

index 0990a8dc221fbca96a392748bc8eea830e7e557a..0c4f352051566a3cea5adbeabcd60ec754fc3ded 100644 (file)
@@ -1,3 +1,10 @@
+2013-07-13  Giuseppe Scrivano  <gscrivano@gnu.org>
+
+       * http.c (digest_authentication_encode): Fix a crash when the algorithm
+       is not specified in the server response.  Free dynamic memory used by
+       the function when the function exits.
+       Reported by: Tim Ruehsen  <tim.ruehsen@gmx.de>.
+
 2013-07-13  Steven M. Schweda <sms@antinode.info>
 
        * warc.c (warc_tempfile): Fix a portability issue on VMS.
index b0c782b94cbac70e4334b075e71035d04b09057a..b2a03c87fd7a879f47a9e3a6506d04e221b63a56 100644 (file)
@@ -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 */