From b2c80f0b616077224e58efc89e8546e17030a159 Mon Sep 17 00:00:00 2001 From: Alexander Vdolainen Date: Thu, 15 Oct 2026 01:36:53 +0300 Subject: [PATCH] Mail processing KNOWN ISSUES has been added; --- KNOWN_ISSUES | 7 +++++++ src/mail_processor.c | 20 +++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 KNOWN_ISSUES diff --git a/KNOWN_ISSUES b/KNOWN_ISSUES new file mode 100644 index 0000000..a4ea535 --- /dev/null +++ b/KNOWN_ISSUES @@ -0,0 +1,7 @@ +Mail processing engine: +1. It trusts 'From' header, probably the better way should be used (IMAP envelope data?) +2. If SMTP fails, message will be lost +3. It checks only 'To:' header, but users might 'Cc:' to mail list +4. Check up for failures in pending pool (extremely rare case, but anyway) +5. Allocation checks +6. Missing logging of different events diff --git a/src/mail_processor.c b/src/mail_processor.c index 4975edf..e0989c8 100644 --- a/src/mail_processor.c +++ b/src/mail_processor.c @@ -551,7 +551,8 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg) return imap_expunge_message(mp->cfg, msg->uid); } - char sender[256], recipient[256]; + /* IMPROVE: more checking up for email addresses */ + char sender[EMAILLEN_MAX], recipient[EMAILLEN_MAX]; extract_email_address(raw_from, sender, sizeof(sender)); extract_email_address(raw_to, recipient, sizeof(recipient)); @@ -559,8 +560,9 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg) free(raw_to); /* ---------------------------------------------------------------------- */ - /* UC 4.3: Subscription Initiation (maillist+subscribe@domain.tld) */ + /* UC 4.3: Subscription case (to is maillist+subscribe@domaintld) */ /* ---------------------------------------------------------------------- */ + /* IMPROVE: extract before at sign and compare */ if (strcasecmp(recipient, "subscribe") == 0 || strstr(recipient, "+subscribe@")) { if (!subscriber_exists(mp->subscribers, sender)) { char token[32]; @@ -591,7 +593,7 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg) { "SUBSCRIBER_ADDR", sender } }; - char tpath[1024]; + char tpath[PATHLEN_MAX]; snprintf(tpath, sizeof(tpath), "%s/subscribe.txt", mp->cfg->template_path); char *body = template_render_file(tpath, vars, 4); @@ -630,7 +632,7 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg) } /* ---------------------------------------------------------------------- */ - /* UC 4.5: Unsubscribe (maillist+unsubscribe@domain.tld) */ + /* UC 4.5: Unsubscribe (to is maillist+unsubscribe@domain.tld) */ /* ---------------------------------------------------------------------- */ if (strcasecmp(recipient, "unsubscribe") == 0 || strstr(recipient, "+unsubscribe@")) { if (subscriber_exists(mp->subscribers, sender)) { @@ -640,9 +642,9 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg) return imap_expunge_message(mp->cfg, msg->uid); } - /* ---------------------------------------------------------------------- */ - /* UC 4.4: Subscription Confirmation (maillist+@domain.tld) */ - /* ---------------------------------------------------------------------- */ + /* ------------------------------------------------------------------------- */ + /* UC 4.4: Subscription confirmation (to is maillist+@domain.tld) */ + /* ------------------------------------------------------------------------- */ char *plus = strchr(recipient, '+'); char *at = strchr(recipient, '@'); if (plus && at && at > plus) { @@ -668,7 +670,7 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg) { "SUBSCRIBER_ADDR", sender } }; - char tpath[1024]; + char tpath[PATHLEN_MAX]; snprintf(tpath, sizeof(tpath), "%s/welcome.txt", mp->cfg->template_path); char *body = template_render_file(tpath, vars, 3); @@ -683,7 +685,7 @@ int mail_processor_execute(mail_processor_t *mp, mail_message_t *msg) } /* ---------------------------------------------------------------------- */ - /* UC 4.2: Normal Broadcast Operation (maillist@domain.tld) */ + /* UC 4.2: Broadcast (maillist@domain.tld) */ /* ---------------------------------------------------------------------- */ if (!subscriber_exists(mp->subscribers, sender)) { /* Drop unauthorized message from non-subscriber */