06_fix_gethostbyname 858 B

12345678910111213141516171819202122232425262728293031
  1. * Mon Feb 5 2001 Preston Brown <pbrown@redhat.com>
  2. - fix gethostbyname to work better with dot "." notation (#16949)
  3. --- tcp_wrappers_7.6/socket.c.fixgethostbyname Fri Mar 21 13:27:25 1997
  4. +++ tcp_wrappers_7.6/socket.c Mon Feb 5 14:09:40 2001
  5. @@ -52,7 +52,8 @@
  6. char *name;
  7. {
  8. char dot_name[MAXHOSTNAMELEN + 1];
  9. -
  10. + struct hostent *hp;
  11. +
  12. /*
  13. * Don't append dots to unqualified names. Such names are likely to come
  14. * from local hosts files or from NIS.
  15. @@ -61,8 +62,12 @@
  16. if (strchr(name, '.') == 0 || strlen(name) >= MAXHOSTNAMELEN - 1) {
  17. return (gethostbyname(name));
  18. } else {
  19. - sprintf(dot_name, "%s.", name);
  20. - return (gethostbyname(dot_name));
  21. + sprintf(dot_name, "%s.", name);
  22. + hp = gethostbyname(dot_name);
  23. + if (hp)
  24. + return hp;
  25. + else
  26. + return (gethostbyname(name));
  27. }
  28. }