summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <cmiller@zippy.cornsilk.net>2008-01-23 11:34:08 -0500
committerunknown <cmiller@zippy.cornsilk.net>2008-01-23 11:34:08 -0500
commit349c2acc212ca09a8fa52e520debfb43d455dca3 (patch)
tree3452532e1c14f20f73d9add8e9f71a127f4c92f7
parent62b11a52cb15532dcb8350dd9e919e7dd1153f07 (diff)
downloadmariadb-git-349c2acc212ca09a8fa52e520debfb43d455dca3.tar.gz
Bug#27427: resolveip fails on hostnames with a leading digit
Patch by Kasper Dupont. No CLA required for this size of patch. "resolveip" program produces incorrect result if given a hostname starting with a digit. Someone seems to have thought that names can not have digits at the beginning. Instead, use the resolver library to work out the rules of hostnames, as it will undoubtedly be better at it than we are. configure.in: See if we need to a library for address lookups. extra/resolveip.c: Don't use silly heuristic to know whether a string is a dotted quad. Instead, pass the whole thing into the resolver and let its smarts do all the work.
-rw-r--r--configure.in2
-rw-r--r--extra/resolveip.c6
2 files changed, 6 insertions, 2 deletions
diff --git a/configure.in b/configure.in
index 63d3976aa3c..cf75aaa38f3 100644
--- a/configure.in
+++ b/configure.in
@@ -838,6 +838,8 @@ AC_CHECK_FUNC(p2open, , AC_CHECK_LIB(gen, p2open))
AC_CHECK_FUNC(bind, , AC_CHECK_LIB(bind, bind))
# Check if crypt() exists in libc or libcrypt, sets LIBS if needed
AC_SEARCH_LIBS(crypt, crypt, AC_DEFINE(HAVE_CRYPT, 1, [crypt]))
+# See if we need a library for address lookup.
+AC_SEARCH_LIBS(inet_aton, [socket nsl resolv])
# For the sched_yield() function on Solaris
AC_CHECK_FUNC(sched_yield, , AC_CHECK_LIB(posix4, sched_yield))
diff --git a/extra/resolveip.c b/extra/resolveip.c
index 1061cafe380..c613f6a8cb6 100644
--- a/extra/resolveip.c
+++ b/extra/resolveip.c
@@ -116,11 +116,13 @@ int main(int argc, char **argv)
while (argc--)
{
+ struct in_addr addr;
ip = *argv++;
- if (my_isdigit(&my_charset_latin1,ip[0]))
+ /* Not compatible with IPv6! Probably should use getnameinfo(). */
+ if (inet_aton(ip, &addr) != 0)
{
- taddr = inet_addr(ip);
+ taddr= addr.s_addr;
if (taddr == htonl(INADDR_BROADCAST))
{
puts("Broadcast");