From 7db61ce021642bb3bbee1c341d94f3539037df80 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Jan 2004 00:32:25 +0400 Subject: 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 --- sql/item_func.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'sql/item_func.cc') 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; -- cgit v1.2.1