[syslog-ng] [PATCH] resolve_sockaddr: Fix domain stripping on initial lookup.

Gergely Nagy algernon at balabit.hu
Wed Nov 2 11:58:37 CET 2011


When looking up a hostname, we were only setting the 'positive' bool
during lookup, so it was only set when the host already existed in the
cache. When it didn't, and we just put it there right after the failed
lookup, the bool remained false.

This resulted in the domain part not being stripped even when
use_fqdn(no) was set.

The fix implemented in this patch is dead simple: if we managed to
resolve a host, we set the bool to TRUE.

Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 lib/misc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/lib/misc.c b/lib/misc.c
index 80f5877..82c2d1b 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -211,7 +211,10 @@ resolve_sockaddr(gchar *result, gsize *result_len, GSockAddr *saddr, gboolean us
                       
                   hp = gethostbyaddr(addr, addr_len, saddr->sa.sa_family);
                   hname = (hp && hp->h_name) ? hp->h_name : NULL;
-                  
+
+                  if (hname)
+                    positive = TRUE;
+
                   if (use_dns_cache && hname)
                     {
                       /* resolution success, store this as a positive match in the cache */
-- 
1.7.7.1




More information about the syslog-ng mailing list