]> diplodocus.org Git - nmh/blobdiff - uip/imaptest.c
SPECS: Use `command-line interface' in one-line summary.
[nmh] / uip / imaptest.c
index 0fa5e26bfb54f5c4bfab0f243a69cfa5884516ac..2032e671a9f039be78109041048c564a336fcd17 100644 (file)
@@ -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 {