Summary: | [patch] SMTP connections fail if IP reverse DNS fails | ||
---|---|---|---|
Product: | [Unmaintained] kio | Reporter: | Thiago Macieira <thiago> |
Component: | smtp | Assignee: | Marc Mutz <mutz> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | SVN | ||
Target Milestone: | --- | ||
Platform: | Unlisted Binaries | ||
OS: | All | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Patch adding brackets to bare IPs in EHLO/HELO |
Description
Thiago Macieira
2003-12-08 20:29:19 UTC
Created attachment 3621 [details]
Patch adding brackets to bare IPs in EHLO/HELO
Here goes the patch. It compiles, but I can't test whether it solves the
problem. At least it doesn't break existing support (that much I've tested).
Subject: kdebase/kioslave/smtp CVS commit by mutz: >From KDE_3_2_BRANCH: Patch by Thiago to fix RFC (2)821 violation: Numeric hostnames must be domain-literals (enclosed in brackets). Took me a while to understand how the patch works (i.e. a grep -R /usr/include NI_NAMEREQD), so I've added a verbose comment explaining it. CCMAIL: 69876-done@bugs.kde.org M +15 -1 smtp.cc 1.140 --- kdebase/kioslave/smtp/smtp.cc #1.139:1.140 @@ -75,4 +75,11 @@ using std::auto_ptr; # include <sys/socket.h> #endif +#include <netdb.h> + +#ifndef NI_NAMEREQD +// FIXME for KDE 3.3: fake defintion +// API design flaw in KExtendedSocket::resolve +# define NI_NAMEREQD 0 +#endif extern "C" { @@ -502,5 +509,12 @@ bool SMTPProtocol::smtp_open(const QStri QString tmpPort; KSocketAddress* addr = KExtendedSocket::localAddress(m_iSock); - KExtendedSocket::resolve(addr, m_hostname, tmpPort); + // perform name lookup. NI_NAMEREQD means: don't return a numeric + // value (we need to know when we get have the IP address, so we + // can enclose it in sqaure brackets (domain-literal). Failure to + // do so is normally harmless with IPv4, but fails for IPv6: + if (KExtendedSocket::resolve(addr, m_hostname, tmpPort, NI_NAMEREQD) != 0) + // FQDN resolution failed + // use the IP address as domain-literal + m_hostname = '[' + addr->nodeName() + ']'; delete addr; |