Bug #27427 resolveip fails on hostnames with a leading digit
Submitted: 25 Mar 2007 19:09 Modified: 28 Jan 2008 17:24
Reporter: Kasper Dupont Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.0.36, mysql-server-5.0.27-1.fc5 OS:Linux (Linux)
Assigned to: Chad MILLER CPU Architecture:Any
Tags: Contribution

[25 Mar 2007 19:09] Kasper Dupont
Description:
resolveip produce incorrect result if given a hostname starting with a digit

How to repeat:
resolveip 42.kasperd.net

Actual results:
Broadcast

Expected results:
IP address of 42.kasperd.net is 80.167.222.169

Suggested fix:
--- mysql-5.0.27/extra/resolveip.c.leadingdigit 2006-10-21 02:22:52.000000000 +0200
+++ mysql-5.0.27/extra/resolveip.c      2007-03-25 15:23:54.000000000 +0200
@@ -107,6 +107,7 @@
 {
   struct hostent *hpaddr;
   in_addr_t taddr;
+  struct in_addr addr;
   char *ip,**q;
   int error=0;
 
@@ -119,9 +120,9 @@
   {
     ip = *argv++;    
 
-    if (my_isdigit(&my_charset_latin1,ip[0]))
+    if (inet_aton(ip, &addr))
     {
-      taddr = inet_addr(ip);
+      taddr = addr.s_addr;
       if (taddr == htonl(INADDR_BROADCAST))
       {
        puts("Broadcast");
[26 Mar 2007 4:54] Valeriy Kravchuk
Thank you for a bug report and patch. Verified just as described.
[27 Mar 2007 14:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/23023

ChangeSet@1.2418, 2007-03-27 10:52:09-04:00, cmiller@zippy.cornsilk.net +1 -0
  Bug#27427: resolveip fails on hostnames with a leading digit
  
  "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.
[27 Mar 2007 16:21] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/23039

ChangeSet@1.2418, 2007-03-27 12:21:19-04:00, cmiller@zippy.cornsilk.net +1 -0
  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.
[28 Mar 2007 19:12] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/23201

ChangeSet@1.2422, 2007-03-28 15:11:38-04:00, cmiller@zippy.cornsilk.net +1 -0
  Bug#27427: resolveip fails on hostnames with a leading digit
  
  We need inet_aton for the extra/resolveip tool.  Some OSes put this
  in nonstandard libraries.
[23 Jan 2008 16:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/41158

ChangeSet@1.2562, 2008-01-23 11:34:08-05:00, cmiller@zippy.cornsilk.net +2 -0
  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.
[28 Jan 2008 6:40] Bugs System
Pushed into 6.0.5-alpha
[28 Jan 2008 6:51] Bugs System
Pushed into 5.1.24-rc
[28 Jan 2008 6:52] Bugs System
Pushed into 5.0.56
[28 Jan 2008 17:24] Paul DuBois
Noted in 5.0.56, 5.1.24, 6.0.5 changelogs.

resolveip failed to produce correct results for hostnames that begin
with a digit.
[6 Mar 2008 5:48] Jon Stephens
Also documented fix for 5.1.23-ndb-6.2.14.
[30 Mar 2008 0:48] Jon Stephens
Also documented fix for 5.1.23-ndb-6.3.11.