Wietse Venema:
> triaxx:
> > postfix/postscreen[22945]: CONNECT from [A.B.C.D]:XXXXX to [E.F.G.H]:25
> > postfix/dnsblog[22947]: panic: dns_query: bad length -1 (h_errno=Unknown 
> > error 0)
> > ...
> > The problem also occurs with 3.2.4. Since I can read this comment, I 
> > suppose a bug:
> >      /*
> >       * Future proofing. If this reaches the panic call, then some code 
> > change
> >       * introduced a bug.
> >       */
> >      if (len < 0)
> >    msg_panic("dns_query: bad length %d (h_errno=%s)",
> >        len, dns_strerror(h_errno));
> 
> This means that the FreeBSD library function res_query() has
> changed, and that it now returns a negative result value (-1) while
> leaving h_errno at zero (i.e. without specifying the error type).
> 
> Maybe this workaround will help. Sorry, no time for diffs. This is
> for dns_res_search() in dns_lookup.c.

Second shot, more portable, nicer error message, and more conservative
action. I'd be interested in any warnings that this will log.

        Wietse

diff --exclude=man --exclude=html --exclude=README_FILES --exclude=INSTALL 
--exclude=.indent.pro --exclude=Makefile.in -r -ur 
/var/tmp/postfix-3.3-20171028/src/dns/dns_lookup.c src/dns/dns_lookup.c
--- /var/tmp/postfix-3.3-20171028/src/dns/dns_lookup.c  2016-02-23 
11:21:41.000000000 -0500
+++ src/dns/dns_lookup.c        2017-12-18 19:22:22.000000000 -0500
@@ -397,6 +397,14 @@
        /* Prepare for returning a null-padded server reply. */
        memset(answer, 0, anslen);
     len = res_query(name, class, type, answer, anslen);
+    /* Begin FreeBSD 11.1 workaround. */
+    if (len < 0 && h_errno == 0) {
+       SET_H_ERRNO(TRY_AGAIN);
+       msg_warn("res_query(\"%s\", %d, %d, %p, %d) returns %d with h_errno==0"
+                " -- setting h_errno=TRY_AGAIN",
+                name, class, type, answer, anslen, len);
+    }
+    /* End FreeBSD 11.1 workaround. */
     if (len > 0) {
        SET_H_ERRNO(0);
     } else if (keep_notfound && NOT_FOUND_H_ERRNO(h_errno)) {

Reply via email to