[PATCH] window-maker/dockapps: fix wmbiff IMAP greeting handling after TLS handshake

8 views
Skip to first unread message

Fredrick W. Warren

unread,
Feb 1, 2026, 2:39:31 PM (yesterday) Feb 1
to wmake...@googlegroups.com
After establishing a TLS connection, IMAP servers send a greeting message (e.g., '* OK IMAP4 ready') before accepting commands. The code was immediately sending CAPABILITY without reading this greeting, causing the greeting to be misinterpreted as a CAPABILITY response.
    
This fix adds code to read and validate the server greeting before sending the CAPABILITY command, resolving connection issues with servers like Fastmail that strictly follow the IMAP protocol.
    
Tested-with: Fastmail (imap.fastmail.com:993), TLS 1.3 Fixes: Connection failures where server greeting was misread

--- wmbiff.orig/wmbiff/Imap4Client.c    2026-02-01 14:29:54.895840849 -0500
+++ wmbiff/wmbiff/Imap4Client.c 2026-02-01 14:32:03.054508297 -0500
@@ -252,6 +252,21 @@
                scs = initialize_unencrypted(sd, connection_name, pc);
        }
 
+       /* READ SERVER GREETING - FIX FOR FASTMAIL AND OTHER SERVERS */
+       /* After TLS handshake, IMAP servers send a greeting like "* OK IMAP4 ready" */
+       /* We must read this before sending any commands */
+       IMAP_DM(pc, DEBUG_INFO, "Reading server greeting after TLS handshake\n");
+       if (tlscomm_expect(scs, "* ", buf, BUF_SIZE) == 0) {
+               IMAP_DM(pc, DEBUG_ERROR, "Failed to receive server greeting after TLS\n");
+               /* Don't fail completely - some servers might not send greeting */
+       } else {
+               IMAP_DM(pc, DEBUG_INFO, "Server greeting: %s\n", buf);
+               /* Verify it's a valid greeting (OK or PREAUTH) */
+               if (strstr(buf, "* OK") == NULL && strstr(buf, "* PREAUTH") == NULL) {
+                       IMAP_DM(pc, DEBUG_INFO, "Unexpected greeting format: %s\n", buf);
+               }
+       }
+
        /* authenticate; first find out how */
        /* note that capabilities may have changed since last
           time we may have asked, if we called STARTTLS, my

Carlos R. Mafra

unread,
Feb 1, 2026, 5:14:23 PM (yesterday) Feb 1
to wmake...@googlegroups.com
On Sun, 1 Feb 2026 at 14:39:00 -0500, Fredrick W. Warren wrote:
> After establishing a TLS connection, IMAP servers send a greeting message (e.g., '* OK IMAP4 ready') before accepting commands. The code was immediately sending CAPABILITY without reading this greeting, causing the greeting to be misinterpreted as a CAPABILITY response.
>
> This fix adds code to read and validate the server greeting before sending the CAPABILITY command, resolving connection issues with servers like Fastmail that strictly follow the IMAP protocol.
>
> Tested-with: Fastmail (imap.fastmail.com:993), TLS 1.3 Fixes: Connection failures where server greeting was misread

Thanks!

Can you send the patch as an attachment?

Reply all
Reply to author
Forward
0 new messages