[6281] in Athena Bugs
[Theodore Ts'o: Patch to res_query.c ]
daemon@ATHENA.MIT.EDU (Theodore Ts'o)
Wed Oct 24 18:00:27 1990
Date: Wed, 24 Oct 90 18:00:03 -0400
From: Theodore Ts'o <tytso@ATHENA.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
Reply-To: tytso@ATHENA.MIT.EDU
Here's a patch to res_query.c to stop it from appending a domain to a
name which already has the domain as a suffix. (As reported by Richard
when he was setting up the Educom workstations.) The patch is based on
bind 4.8.3, but the only difference between the it and the one that's in
/source is the copyright notice and the #include of string.h instead of
strings.h --- so patch should have no problems with it except that the
line numbers will be offset by a little.
Note that nslookup does not use res_search(), but rather its own
routines in getinfo.c; thus, nslookup can't be used to test this patch.
The best way I found to test the patch was to load the entire resolver
routines into saber and test it using gethostbyname().
- Ted
*** /tmp/,RCSt1008665 Wed Oct 24 16:25:51 1990
--- res_query.c Wed Oct 24 16:25:27 1990
***************
*** 39,44 ****
--- 39,46 ----
#define MAXPACKET 1024
#endif
+ #define SUFFIX_CHECK
+
extern int errno;
int h_errno;
***************
*** 226,234 ****
nbuf[n] = '\0';
} else
longname = name;
! } else
(void)sprintf(nbuf, "%.*s.%.*s",
MAXDNAME, name, MAXDNAME, domain);
return (res_query(longname, class, type, answer, anslen));
}
--- 228,253 ----
nbuf[n] = '\0';
} else
longname = name;
! } else {
! #ifdef SUFFIX_CHECK
! /*
! * Check to see if the domain that we're about to
! * append is already present as the suffix of name.
! * If so, assume that adding the suffix will be a
! * waste of time.... so punt.
! * [tytso:19901024.1625EDT]
! */
! int offset = strlen(name) - strlen(domain);
!
! if ((offset >= 0 ) && !strcasecmp(name+offset, domain) &&
! ((offset == 0) || (*(name+offset-1)=='.')))
! return(-1); /* Tell res_search to try again */
! #endif
!
(void)sprintf(nbuf, "%.*s.%.*s",
MAXDNAME, name, MAXDNAME, domain);
+ }
+
return (res_query(longname, class, type, answer, anslen));
}