X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/36672e5977cdfee454f5ccb1946a19cd43ec5ba0..2ea6899cdfc1dabed68a587cd1f38093180cc206:/uip/popsbr.c diff --git a/uip/popsbr.c b/uip/popsbr.c index d79c8b3d..ac1117be 100644 --- a/uip/popsbr.c +++ b/uip/popsbr.c @@ -34,7 +34,7 @@ static int vcommand(const char *, va_list) CHECK_PRINTF(1, 0); static int pop_getline (char *, int, netsec_context *); static int pop_sasl_callback(enum sasl_message_type, unsigned const char *, unsigned int, unsigned char **, unsigned int *, - char **); + void *, char **); static int check_mech(char *server_mechs, size_t server_mechs_size) @@ -223,7 +223,7 @@ pop_init (char *host, char *port, char *user, char *proxy, int snoop, if (sasl) { if (netsec_set_sasl_params(nsc, "pop", mech, pop_sasl_callback, - &errstr) != OK) { + NULL, &errstr) != OK) { snprintf(response, sizeof(response), "%s", errstr); free(errstr); return NOTOK; @@ -292,11 +292,12 @@ pop_init (char *host, char *port, char *user, char *proxy, int snoop, static int pop_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, unsigned int indatalen, unsigned char **outdata, - unsigned int *outdatalen, char **errstr) + unsigned int *outdatalen, void *context, char **errstr) { int rc, snoopoffset; char *mech, *line; size_t len, b64len; + NMH_UNUSED(context); switch (mtype) { case NETSEC_SASL_START: @@ -338,25 +339,27 @@ pop_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, "for initial challenge response"); return NOTOK; } - netsec_set_snoop_callback(nsc, netsec_b64_snoop_decoder, NULL); rc = netsec_printf(nsc, errstr, "%s\r\n", b64data); - netsec_set_snoop_callback(nsc, NULL, NULL); free(b64data); if (rc != OK) return NOTOK; - if (netsec_flush(nsc, errstr) != OK) + netsec_set_snoop_callback(nsc, netsec_b64_snoop_decoder, NULL); + rc = netsec_flush(nsc, errstr); + netsec_set_snoop_callback(nsc, NULL, NULL); + if (rc != OK) return NOTOK; } else { - netsec_set_snoop_callback(nsc, netsec_b64_snoop_decoder, - &snoopoffset); - snoopoffset = 6 + strlen(mech); rc = netsec_printf(nsc, errstr, "AUTH %s %s\r\n", mech, b64data); free(b64data); - netsec_set_snoop_callback(nsc, NULL, NULL); if (rc != OK) return NOTOK; - if (netsec_flush(nsc, errstr) != OK) + netsec_set_snoop_callback(nsc, netsec_b64_snoop_decoder, + &snoopoffset); + snoopoffset = 6 + strlen(mech); + rc = netsec_flush(nsc, errstr); + netsec_set_snoop_callback(nsc, NULL, NULL); + if (rc != OK) return NOTOK; } } else { @@ -409,16 +412,18 @@ pop_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, unsigned char *b64data; b64data = mh_xmalloc(BASE64SIZE(indatalen)); writeBase64raw(indata, indatalen, b64data); - netsec_set_snoop_callback(nsc, netsec_b64_snoop_decoder, NULL); rc = netsec_printf(nsc, errstr, "%s\r\n", b64data); - netsec_set_snoop_callback(nsc, NULL, NULL); free(b64data); } if (rc != OK) return NOTOK; - if (netsec_flush(nsc, errstr) != OK) + if (indatalen > 0) + netsec_set_snoop_callback(nsc, netsec_b64_snoop_decoder, NULL); + rc = netsec_flush(nsc, errstr); + netsec_set_snoop_callback(nsc, NULL, NULL); + if (rc != OK) return NOTOK; break;