GNOME Bugzilla – Bug 336035
HELO greeting violates RFC2821
Last modified: 2006-04-18 18:16:12 UTC
Please describe the problem: When sitting in the airport on a wireless connection which seems to work for free, I unfortunately have an IP address where the reverse DNS is operated by idiots and contains underscores: 61_219_103_66-WIFI_HOTSPOTS.eng.telusmobility.com Two problems result from this. Firstly, Evolution violates RFC2821 by using that name in the EHLO greeting when sending mail, and is rightly told to sod off by my mail server: sending : EHLO 61_219_103_66-WIFI_HOTSPOTS.eng.telusmobility.com received: 250-pentafluge.infradead.org Hello 61_219_103_66-WIFI_HOTSPOTS.eng.telusmobility.com [66.103.219.61] received: 250-SIZE 52428800 received: 250-8BITMIME This server supports 8bit MIME received: 250-ETRN received: 250-EXPN received: 250-STARTTLS This server supports STARTTLS received: 250 HELP sending : STARTTLS received: 220 TLS go ahead sending : EHLO 61_219_103_66-WIFI_HOTSPOTS.eng.telusmobility.com received: 250-pentafluge.infradead.org Hello 61_219_103_66-WIFI_HOTSPOTS.eng.telusmobility.com [66.103.219.61] received: 250-SIZE 52428800 received: 250-8BITMIME This server supports 8bit MIME received: 250-ETRN received: 250-EXPN received: 250-AUTH LOGIN PLAIN CRAM-MD5 received: 250 HELP <...> received: 235 Authentication succeeded sending : MAIL FROM:<dwmw2@infradead.org> received: 250 OK sending : RCPT TO:<Massimo.Gaetani@mvhi.com> received: 550-Mail rejected. Underscores in HELO are not permitted by RFC2821. (The second problem is that Evolution misreports the error message, so I have to either run with CAMEL_VERBOSE_DEBUG=1 or log in to the mail server and look at the logs in order to see what _actually_ happened. Instead of reporting the above error message, Evolution makes something up -- it says "Requested action not taken: mailbox unavailable". That's filed as bug #248873) Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Created attachment 62016 [details] [review] patch This fixes the problem by validating what we're going to say in HELO before sending it, and falling back to an IP literal if it would violate RFC2821.
Comment on attachment 62016 [details] [review] patch --- evolution-data-server-1.6.0/camel/providers/smtp/camel-smtp-transport.c.validatehelo 2005-08-31 05:26:04.000000000 +0100 +++ evolution-data-server-1.6.0/camel/providers/smtp/camel-smtp-transport.c 2006-04-04 23:27:23.000000000 +0100 @@ -873,6 +873,43 @@ smtp_set_exception (CamelSmtpTransport * } static gboolean +hostname_is_valid(const char *name) +{ + enum { ALNUM, DASH, DOT } state = DOT; + int dotseen = 0; + + if (!name) + return FALSE; + + while (*name) { + switch(state) { + case ALNUM: + if (*name == '-') { + state = DASH; + break; + } else if (*name == '.') { + dotseen = 1; + state = DOT; + break; + } /* else ... */ + case DOT: + case DASH: + if (!isalnum(*name)) + return FALSE; + state = ALNUM; + break; + } + name++; + } + + /* If it didn't end with an alphanumeric character, or there were no dots, it's invalid */ + if (state != ALNUM || !dotseen) + return FALSE; + else + return TRUE; +} + +static gboolean smtp_helo (CamelSmtpTransport *transport, CamelException *ex) { /* say hello to the server */ @@ -893,8 +930,14 @@ smtp_helo (CamelSmtpTransport *transport camel_operation_start_transient (NULL, _("SMTP Greeting")); - /* force name resolution first, fallback to numerical, we need to know when it falls back */ - if (camel_getnameinfo(transport->localaddr, transport->localaddrlen, &name, NULL, NI_NAMEREQD, NULL) != 0) { + /* force name resolution first, but check the resulting name is valid according to RFC2821 */ + if (camel_getnameinfo(transport->localaddr, transport->localaddrlen, &name, NULL, NI_NAMEREQD, NULL) || + !hostname_is_valid(name)) { + g_free(name); + name = NULL; + } + /* If the name lookup failed, or the name wasn't acceptable, then try to use a numeric HELO domain */ + if (!name) { if (camel_getnameinfo(transport->localaddr, transport->localaddrlen, &name, NULL, NI_NUMERICHOST, NULL) != 0) name = g_strdup("localhost.localdomain"); else {
was this latest version of the patch ever committed?
Not by me.
committed a patch to CVS
Thanks