imap_sasl_callback() protocol check is incomplete
Stephen Gildea <[email protected]> Sun, 29 Jun 2025 11:29:55 -0700
| Newsgroups | gmane.mail.nmh.devel |
|---|---|
| Message-ID | <[email protected]> |
When function 'imap_sasl_callback' reads a response from the server, it appears that it intends to check that the first 2 characters are "+ ". Actually, the code checks this only in the case of a blank response, because the check is limited by testing if "len == 2". This patch replaces the whole multi-clause test with a call to has_prefix_len(), making the code both correct and more readable.
sasl_callback_read_protocol_check.diff
(text/x-diff, 445 B)
diff --git a/uip/imaptest.c b/uip/imaptest.c
index 8167a7ff..5d891420 100644
--- a/uip/imaptest.c
+++ b/uip/imaptest.c
@@ -644,7 +644,7 @@ imap_sasl_callback(enum sasl_message_type mtype, unsigned const char *indata,
if (line == NULL)
return NOTOK;
- if (len < 2 || (len == 2 && strcmp(line, "+ ") != 0)) {
+ if (!has_prefix_len(line, len, "+ ")) {
netsec_err(errstr, "Invalid format for SASL response");
return NOTOK;
}