diff options
author | monty@tik.mysql.fi <> | 2002-04-06 18:47:54 +0300 |
---|---|---|
committer | monty@tik.mysql.fi <> | 2002-04-06 18:47:54 +0300 |
commit | e857f561fd2fc2e544cba9508884c539ee789b05 (patch) | |
tree | 3e5cd66c625da56736e12e3ad5fdd667c31f4149 /sql | |
parent | 4cae9fe9b3606ac1f9324cdb457cbd210473193a (diff) | |
download | mariadb-git-e857f561fd2fc2e544cba9508884c539ee789b05.tar.gz |
Fix for INET_NTOA(N) when N >= 2^32
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_strfunc.cc | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 602cd7e38be..9d24ca19b4c 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1921,24 +1921,23 @@ String* Item_func_inet_ntoa::val_str(String* str) uchar buf[8], *p; ulonglong n = (ulonglong) args[0]->val_int(); char num[4]; + /* - we do not know if args[0] is NULL until we have called + We do not know if args[0] is NULL until we have called some val function on it if args[0] is not a constant! + + Also return null if n > 255.255.255.255 */ - if ((null_value=args[0]->null_value)) + if ((null_value= (args[0]->null_value || n > (ulonglong) LL(4294967295)))) return 0; // Null value str->length(0); - int8store(buf,n); + int4store(buf,n); - /* - Now we can assume little endian. - We handle the possibility of an 8-byte IP address however, we do - not want to confuse those who are just using 4 byte ones - */ - for (p= buf + 8; p > buf+4 && p[-1] == 0 ; p-- ) ; + /* Now we can assume little endian. */ + num[3]='.'; - while (p-- > buf) + for (p=buf+4 ; p-- > buf ; ) { uint c = *p; uint n1,n2; // Try to avoid divisions |