diff options
author | unknown <vva@eagle.mysql.r18.ru> | 2004-01-20 00:32:25 +0400 |
---|---|---|
committer | unknown <vva@eagle.mysql.r18.ru> | 2004-01-20 00:32:25 +0400 |
commit | 7db61ce021642bb3bbee1c341d94f3539037df80 (patch) | |
tree | 9f7467f26608a50aa2d2fe9896d5eb28313b8810 /sql/item_func.cc | |
parent | a66924353a9fb4a1c1bfa05ad45aa3cabc34c3b6 (diff) | |
download | mariadb-git-7db61ce021642bb3bbee1c341d94f3539037df80.tar.gz |
Fixed bug #2310 "INET_ATON handles short-forms addresses incorrectly"
mysql-test/r/func_misc.result:
added new test for inet_aton (short-forms addresses)
mysql-test/t/func_misc.test:
added new test for inet_aton (short-forms addresses)
sql/item_func.cc:
Change Item_func_inet_aton::val_int to parse short-forms addresses correctly
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 5af64ca0be4..802b6dbb8d6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -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; |