Commit 3b98955a authored by unknown's avatar unknown

Merge vvagin@bk-internal.mysql.com:/home/bk/mysql-4.1

into eagle.mysql.r18.ru:/home/vva/work/BUG_2310/mysql-4.1

parents d2b54441 7db61ce0
......@@ -6,10 +6,19 @@ inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"))
NULL
select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
inet_aton("255.255.255.255.255") inet_aton("255.255.1.255") inet_aton("0.1.255")
1099511627775 4294902271 511
1099511627775 4294902271 65791
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
inet_ntoa(1099511627775) inet_ntoa(4294902271) inet_ntoa(511)
NULL 255.255.1.255 0.0.1.255
select hex(inet_aton('127'));
hex(inet_aton('127'))
7F
select hex(inet_aton('127.1'));
hex(inet_aton('127.1'))
7F000001
select hex(inet_aton('127.1.1'));
hex(inet_aton('127.1.1'))
7F010001
select length(format('nan', 2)) > 0;
length(format('nan', 2)) > 0
1
......
......@@ -8,6 +8,10 @@ select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"));
select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
select hex(inet_aton('127'));
select hex(inet_aton('127.1'));
select hex(inet_aton('127.1.1'));
#
# Test for core dump with nan
#
......
......@@ -2618,6 +2618,7 @@ longlong Item_func_inet_aton::val_int()
const char *p,* end;
char c = '.'; // we mark c to indicate invalid IP in case length is 0
char buff[36];
int dot_count= 0;
String *s,tmp(buff,sizeof(buff),&my_charset_bin);
if (!(s = args[0]->val_str(&tmp))) // If null value
......@@ -2636,6 +2637,7 @@ longlong Item_func_inet_aton::val_int()
}
else if (c == '.')
{
dot_count++;
result= (result << 8) + (ulonglong) byte_result;
byte_result = 0;
}
......@@ -2643,7 +2645,14 @@ longlong Item_func_inet_aton::val_int()
goto err; // Invalid character
}
if (c != '.') // IP number can't end on '.'
{
switch (dot_count)
{
case 1: result<<= 8;
case 2: result<<= 8;
}
return (result << 8) + (ulonglong) byte_result;
}
err:
null_value=1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment