Handle large DNS messages
From: Rob Napier <rnapier@xxxxxxxxx>
Date: Tue, 3 Nov 2009 02:43:51 +0100 (CET)
My understanding of res_querydomain() is that it will automatically re- try in TCP if it truncates. However, it will set the "tc" flag in HEADER to 1 nonetheless. Therefore, testing for "tc" is not helpful, unless RES_IGNTC is set (and that flag is ignored anyway, so it never matters).

So if your SRV record response is very large (like ours), and you truncate in UDP, it re-tried in TCP, but Gloox fails anyway.

The fix, I believe, is to change dns.cpp as follows:

--- dns.cpp.orig        2009-11-02 19:39:43.000000000 -0500
+++ dns.cpp     2009-11-02 19:40:31.000000000 -0500
@@ -98,7 +98,7 @@
     HEADER* hdr = (HEADER*)srvbuf.buf;
     unsigned char* here = srvbuf.buf + NS_HFIXEDSZ;

-    if( ( hdr->tc ) || ( srvbuf.len < NS_HFIXEDSZ ) )
+    if( srvbuf.len < NS_HFIXEDSZ )
       error = true;

     if( hdr->rcode >= 1 && hdr->rcode <= 5 )