summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@tik.mysql.fi>2002-04-06 18:47:54 +0300
committerunknown <monty@tik.mysql.fi>2002-04-06 18:47:54 +0300
commit40a27740878e945bbdf667c3735a41727d343ed1 (patch)
tree3e5cd66c625da56736e12e3ad5fdd667c31f4149 /sql
parent1f38c3a93d2bd5c2d38d63eb283c62647be0343a (diff)
downloadmariadb-git-40a27740878e945bbdf667c3735a41727d343ed1.tar.gz
Fix for INET_NTOA(N) when N >= 2^32
Docs/manual.texi: SCO updates client/mysql.cc: Don't die on SIGQUIT
Diffstat (limited to 'sql')
-rw-r--r--sql/item_strfunc.cc19
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