X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fdigest.c;h=22912157c4c3c777b5d79c49f052384353f4f3bb;hb=06582fecd198c26f1970a2e779e7bd9519e60cd2;hp=132f27e33b2f7c9aa0db3f7541f893b5d6b921fc;hpb=e4169f77f892fefc66a97439d295d3e09ef3e2f0;p=deb_shairplay.git diff --git a/src/lib/digest.c b/src/lib/digest.c index 132f27e..2291215 100644 --- a/src/lib/digest.c +++ b/src/lib/digest.c @@ -73,14 +73,14 @@ digest_generate_nonce(char *result, int resultlen) MD5_Final(md5buf, &md5ctx); digest_md5_to_hex(md5buf, md5hex); + memset(result, 0, resultlen); strncpy(result, md5hex, resultlen-1); - result[resultlen-1] = '\0'; } int digest_is_valid(const char *our_realm, const char *password, const char *our_nonce, const char *method, - const char *authorization) + const char *our_uri, const char *authorization) { char *auth; char *current; @@ -140,6 +140,15 @@ digest_is_valid(const char *our_realm, const char *password, response = first+10; } + if (!username || !realm || !nonce || !uri || !response) { + free(auth); + return 0; + } + if (strcmp(realm, our_realm) || strcmp(nonce, our_nonce) || strcmp(uri, our_uri)) { + free(auth); + return 0; + } + /* Calculate our response */ memset(our_response, 0, sizeof(our_response)); digest_get_response(username, realm, password, nonce,