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