Skip to content

Commit 19d9a65

Browse files
author
Oleksii Molchanov
committed
Free the previous nonce before storing a nextnonce.
auc_digest_info() stores the server-supplied Authentication-Info nextnonce over cda->cda_ac->ac_nonce without releasing what was there: n = auth_get_params(home, info->ai_params, "nextnonce=", &nextnonce, NULL); if (n <= 0) return n; cda->cda_ac->ac_nonce = nextnonce; auth_get_params() allocates the new string from `home`, and the pointer being overwritten is owned by that same home: it came either from the challenge via auth_digest_challenge_get(), or from an earlier Authentication-Info through this same assignment. The consequence is not "one leak per nonce" but "all but the last": the next challenge calls auth_digest_challenge_free_params(), which does release ac_nonce - so of N responses carrying nextnonce between two challenges, N-1 strings are lost. A server that sends Authentication-Info on every 2xx therefore leaks one nonce string per response for as long as the credentials stay valid. Like every other object in this family the block is allocated from a su_home and stays reachable through the home's block table, so no leak checker reports it; it shows up only as heap growth proportional to the response rate. The free follows the discipline the rest of the file already uses - auth_digest_challenge_free_params() at auth_digest.c:126, and the cnonce path in auc_digest_challenge(), both su_free() from ca_home before replacing. su_free() ignores NULL, so the first nextnonce on a fresh client is unaffected.
1 parent ad36ac8 commit 19d9a65

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎libsofia-sip-ua/iptsec/auth_client.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,13 @@ static int auc_digest_info(auth_client_t *ca,
907907
if (n <= 0)
908908
return n;
909909

910+
/* The nonce being replaced is owned by this home - it came either from the
911+
* challenge, via auth_digest_challenge_get(), or from an earlier
912+
* Authentication-Info through this same assignment. Without this free only
913+
* the last one is ever released, by auth_digest_challenge_free_params() at
914+
* the next challenge, so a server that sends nextnonce on every response
915+
* loses one nonce string per response until then. su_free() ignores NULL. */
916+
su_free(home, (void *)cda->cda_ac->ac_nonce);
910917
cda->cda_ac->ac_nonce = nextnonce;
911918

912919
return 1;

0 commit comments

Comments
 (0)