Commit b001a522 authored by Ramil Kalimullin's avatar Ramil Kalimullin

Fix for bug#57283: inet_ntoa() crashes

Problem: some call of INET_NTOA() function may lead 
to a crash due to missing its character set initialization.

Fix: explicitly set the character set.


mysql-test/r/func_misc.result:
  Fix for bug#57283: inet_ntoa() crashes
    - test result.
mysql-test/t/func_misc.test:
  Fix for bug#57283: inet_ntoa() crashes
    - test case.
sql/item_strfunc.cc:
  Fix for bug#57283: inet_ntoa() crashes
    - explicitly set buffer's character set.
parent 42550e21
...@@ -351,4 +351,10 @@ GREATEST(a, (SELECT b FROM t1 LIMIT 1)) ...@@ -351,4 +351,10 @@ GREATEST(a, (SELECT b FROM t1 LIMIT 1))
3 3
1 1
DROP TABLE t1; DROP TABLE t1;
SELECT INET_NTOA(0);
INET_NTOA(0)
0.0.0.0
SELECT '1' IN ('1', INET_NTOA(0));
'1' IN ('1', INET_NTOA(0))
1
End of tests End of tests
...@@ -479,4 +479,12 @@ SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1; ...@@ -479,4 +479,12 @@ SELECT DISTINCT GREATEST(a, (SELECT b FROM t1 LIMIT 1)) FROM t1 UNION SELECT 1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #57283: inet_ntoa() crashes
#
SELECT INET_NTOA(0);
SELECT '1' IN ('1', INET_NTOA(0));
--echo End of tests --echo End of tests
...@@ -3135,6 +3135,7 @@ String* Item_func_inet_ntoa::val_str(String* str) ...@@ -3135,6 +3135,7 @@ String* Item_func_inet_ntoa::val_str(String* str)
if ((null_value= (args[0]->null_value || n > (ulonglong) LL(4294967295)))) if ((null_value= (args[0]->null_value || n > (ulonglong) LL(4294967295))))
return 0; // Null value return 0; // Null value
str->set_charset(collation.collation);
str->length(0); str->length(0);
int4store(buf,n); int4store(buf,n);
......
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