# include "config.h"
#endif
+#include <lib-lib/mem.h>
+
#include "mutt.h"
#include "account.h"
#include "mutt_sasl.h"
#include "mutt_socket.h"
-#include "lib/mem.h"
#include "lib/debug.h"
#include <errno.h>
if (ret)
return getnameinfo_err (ret);
- if (outlen < str_len (hbuf) + str_len (pbuf) + 2)
+ if (outlen < m_strlen(hbuf) + m_strlen(pbuf) + 2)
return SASL_BUFOVER;
snprintf (out, outlen, "%s;%s", hbuf, pbuf);
* just fall back to LOGIN in the IMAP case anyway. If that doesn't
* work for POP, we can make it a flag or move this code into
* imap/auth_sasl.c */
- memset (&secprops, 0, sizeof (secprops));
+ p_clear(&secprops, 1);
/* Work around a casting bug in the SASL krb4 module */
secprops.max_ssf = 0x7fff;
secprops.maxbufsize = M_SASL_MAXBUF;
if (mutt_get_field (prompt, resp, sizeof (resp), 0))
return SASL_FAIL;
- interaction->len = str_len (resp) + 1;
- interaction->result = mem_malloc (interaction->len);
- memcpy ((char*) interaction->result, resp, interaction->len);
-
+ interaction->len = m_strlen(resp) + 1;
+ interaction->result = p_dupstr(resp, interaction->len - 1);
interaction++;
}
* for the read/write methods. */
void mutt_sasl_setup_conn (CONNECTION * conn, sasl_conn_t * saslconn)
{
- SASL_DATA *sasldata = (SASL_DATA *) mem_malloc (sizeof (SASL_DATA));
+ SASL_DATA *sasldata = p_new(SASL_DATA, 1);
sasldata->saslconn = saslconn;
/* get ssf so we know whether we have to (en|de)code read/write */
- sasl_getprop (saslconn, SASL_SSF, (const void **) &sasldata->ssf);
+ sasl_getprop (saslconn, SASL_SSF, (const void **)(void *)&sasldata->ssf);
debug_print (3, ("SASL protection strength: %u\n", *sasldata->ssf));
/* Add SASL SSF to transport SSF */
conn->ssf += *sasldata->ssf;
sasl_getprop (saslconn, SASL_MAXOUTBUF,
- (const void **) &sasldata->pbufsize);
+ (const void **)(void *)&sasldata->pbufsize);
debug_print (3, ("SASL protection buffer size: %u\n", *sasldata->pbufsize));
/* clear input buffer */
}
if (len)
- *len = str_len (*result);
+ *len = m_strlen(*result);
return SASL_OK;
}
if (mutt_account_getpass (account))
return SASL_FAIL;
- len = str_len (account->pass);
+ len = m_strlen(account->pass);
- *psecret = (sasl_secret_t *) mem_malloc (sizeof (sasl_secret_t) + len);
+ *psecret = xmalloc(sizeof(sasl_secret_t) + len);
(*psecret)->len = len;
strcpy ((char*) (*psecret)->data, account->pass); /* __STRCPY_CHECKED__ */
/* release sasl resources */
sasl_dispose (&sasldata->saslconn);
- mem_free (&sasldata->buf);
- mem_free (&sasldata);
+ p_delete(&sasldata->buf);
+ p_delete(&sasldata);
/* call underlying close */
rc = (conn->conn_close) (conn);
conn->sockdata = sasldata->sockdata;
- mem_free (&sasldata->buf);
+ p_delete(&sasldata->buf);
sasldata->bpos = 0;
sasldata->blen = 0;
}
rc = (sasldata->msasl_write) (conn, pbuf, plen);
- mem_free (&pbuf);
+ p_delete(&pbuf);
if (rc != plen)
goto fail;