X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0f654f924e450f12fda24775cd51cdcc2b41b516..6547ca9f73c3f02b2356017bbd7ff85292f8e4a1:/uip/imaptest.c diff --git a/uip/imaptest.c b/uip/imaptest.c index 0fa5e26b..2032e671 100644 --- a/uip/imaptest.c +++ b/uip/imaptest.c @@ -73,14 +73,14 @@ static int capability_set(const char *); static void clear_capability(void); static int have_capability(void); static int send_imap_command(netsec_context *, int noflush, char **errstr, - const char *fmt, ...); + const char *fmt, ...) CHECK_PRINTF(4, 5); static int get_imap_response(netsec_context *, const char *token, char **tokenresp, char **status, int failerr, char **errstr); static void ts_report(const char *str, struct timeval *tv); -static void add_msg(int queue, const char *fmt, ...); +static void add_msg(int queue, const char *fmt, ...) CHECK_PRINTF(2, 3); static bool timestamp = false; @@ -216,20 +216,20 @@ main (int argc, char **argv) if (initialtls || tls) { if (netsec_set_tls(nsc, 1, 0, &errstr) != OK) - adios(NULL, errstr); + adios(NULL, "%s", errstr); if (initialtls && netsec_negotiate_tls(nsc, &errstr) != OK) - adios(NULL, errstr); + adios(NULL, "%s", errstr); } if (sasl) { if (netsec_set_sasl_params(nsc, "imap", saslmech, imap_sasl_callback, nsc, &errstr) != OK) - adios(NULL, errstr); + adios(NULL, "%s", errstr); } if ((cp = netsec_readline(nsc, &len, &errstr)) == NULL) { - adios(NULL, errstr); + adios(NULL, "%s", errstr); } if (has_prefix(cp, "* BYE")) { @@ -295,7 +295,7 @@ main (int argc, char **argv) goto finish; } if (netsec_negotiate_tls(nsc, &errstr) != OK) { - adios(NULL, errstr); + adios(NULL, "%s", errstr); } } @@ -417,7 +417,7 @@ parse_capability(const char *cap, unsigned int len) } for (i = 0; caplist[i] != NULL; i++) { - if (has_prefix(caplist[i], "AUTH=") && caplist[i] + 5 != '\0') { + if (has_prefix(caplist[i], "AUTH=") && *(caplist[i] + 5) != '\0') { if (saslmechs) { saslmechs = add(" ", saslmechs); } @@ -427,7 +427,6 @@ parse_capability(const char *cap, unsigned int len) } } - free(caplist); free(str); } @@ -598,6 +597,7 @@ imap_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, */ case NETSEC_SASL_FINISH: + line = NULL; if (get_imap_response(nsc, NULL, NULL, &line, 1, errstr) != OK) return NOTOK; /* @@ -605,7 +605,7 @@ imap_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata, * parse it. */ - if (has_prefix(line, "OK [CAPABILITY ")) { + if (line && has_prefix(line, "OK [CAPABILITY ")) { char *p = line + 15, *q; q = strchr(p, ']'); @@ -709,7 +709,7 @@ getline: if (has_prefix(line, cmdqueue->tag)) { cmd = cmdqueue; if (timestamp) - ts_report("Command execution time:", &cmd->start); + ts_report("Command execution time", &cmd->start); cmdqueue = cmd->next; free(cmd); } else {