Added a block to smtp_mailaddr() in smtp_session.c to allow for quoted
usernames. Only tested on my laptop and seems to work. However, I'm
thinking it might should be moved past the point of splitting on ':'.

Edgar
Index: smtp_session.c
===================================================================
RCS file: /cvs/src/usr.sbin/smtpd/smtp_session.c,v
retrieving revision 1.429
diff -u -p -u -r1.429 smtp_session.c
--- smtp_session.c      5 Mar 2021 12:37:32 -0000       1.429
+++ smtp_session.c      10 Apr 2021 12:57:55 -0000
@@ -1,4 +1,4 @@
-/*     $OpenBSD: smtp_session.c,v 1.429 2021/03/05 12:37:32 eric Exp $ */
+/*     $OpenBSD: smtp_sesson.c,v 1.429 2021/03/05 12:37:32 eric Exp $  */
 
 /*
  * Copyright (c) 2008 Gilles Chehade <gil...@poolp.org>
@@ -2224,7 +2224,7 @@ static int
 smtp_mailaddr(struct mailaddr *maddr, char *line, int mailfrom, char **args,
     const char *domain)
 {
-       char   *p, *e;
+       char   *p, *e, *q, *s;
 
        if (line == NULL)
                return (0);
@@ -2233,15 +2233,28 @@ smtp_mailaddr(struct mailaddr *maddr, ch
                return (0);
 
        e = strchr(line, '>');
+
        if (e == NULL)
                return (0);
+
        *e++ = '\0';
+
        while (*e == ' ')
                e++;
        *args = e;
 
        if (!text_to_mailaddr(maddr, line + 1))
                return (0);
+
+       q = strchr(maddr->user, '"');
+       if (q != NULL) {
+               q++;
+               s = strrchr(q, '"');
+               if (s == NULL)
+                       return (0);
+               *s = '\0';
+               memmove(maddr->user, q, strlen(q) + 1);
+       }
 
        p = strchr(maddr->user, ':');
        if (p != NULL) {

Reply via email to