changeset: 6725:b2cb7a38c1ed user: Will Fiveash <[email protected]> date: Sat Jul 16 14:04:29 2016 -0700 link: http://dev.mutt.org/hg/mutt/rev/b2cb7a38c1ed
Fix memory leak in mutt_sasl_cb_pass. SASL doesn't free the sasl_secret_t, so this was leaking. Instead, keep our own pointer to it, and safe_realloc() each time. sasl_secret_t doesn't need the data field null terminated, so memcpy the password over. diffs (26 lines): diff -r 488f91a85115 -r b2cb7a38c1ed mutt_sasl.c --- a/mutt_sasl.c Tue Jul 12 18:04:28 2016 -0700 +++ b/mutt_sasl.c Sat Jul 16 14:04:29 2016 -0700 @@ -84,6 +84,8 @@ static sasl_callback_t mutt_sasl_callbacks[5]; +static sasl_secret_t *secret_ptr = NULL; + static int mutt_sasl_start (void); /* callbacks */ @@ -445,9 +447,10 @@ len = strlen (account->pass); - *psecret = (sasl_secret_t*) safe_malloc (sizeof (sasl_secret_t) + len); - (*psecret)->len = len; - strcpy ((char*)(*psecret)->data, account->pass); /* __STRCPY_CHECKED__ */ + safe_realloc (&secret_ptr, sizeof (sasl_secret_t) + len); + memcpy ((char *) secret_ptr->data, account->pass, (size_t) len); + secret_ptr->len = len; + *psecret = secret_ptr; return SASL_OK; }
