summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Didriksen <tor.didriksen@oracle.com>2013-09-09 14:20:50 +0200
committerTor Didriksen <tor.didriksen@oracle.com>2013-09-09 14:20:50 +0200
commita50170dd0c1f4a7e347ccc4cca85c3f5fe845299 (patch)
tree89c449538f7571b65d5ba39fcc0b27938eed672b
parent90ecf4eba33692e76a83a57be2bc061199a72912 (diff)
downloadmariadb-git-a50170dd0c1f4a7e347ccc4cca85c3f5fe845299.tar.gz
Bug#17296644 CONV(X, INT_MIN, INT_MIN) SEGFAULTS THE SERVER
Do not call abs(INT_MIN) as the result is undefined.
-rw-r--r--configure.cmake4
-rw-r--r--sql/item_strfunc.cc4
2 files changed, 7 insertions, 1 deletions
diff --git a/configure.cmake b/configure.cmake
index 3474f12f1e1..c3ac3a8222f 100644
--- a/configure.cmake
+++ b/configure.cmake
@@ -147,6 +147,10 @@ IF(UNIX)
SET(CMAKE_REQUIRED_LIBRARIES
${LIBM} ${LIBNSL} ${LIBBIND} ${LIBCRYPT} ${LIBSOCKET} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT} ${LIBRT})
+ # Need explicit pthread for gcc -fsanitize=address
+ IF(CMAKE_USE_PTHREADS_INIT AND CMAKE_C_FLAGS MATCHES "-fsanitize=")
+ SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} pthread)
+ ENDIF()
LIST(LENGTH CMAKE_REQUIRED_LIBRARIES required_libs_length)
IF(${required_libs_length} GREATER 0)
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index f654d260564..363ca02fd7a 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2928,7 +2928,9 @@ String *Item_func_conv::val_str(String *str)
int to_base= (int) args[2]->val_int();
int err;
+ // Note that abs(INT_MIN) is undefined.
if (args[0]->null_value || args[1]->null_value || args[2]->null_value ||
+ from_base == INT_MIN || to_base == INT_MIN ||
abs(to_base) > 36 || abs(to_base) < 2 ||
abs(from_base) > 36 || abs(from_base) < 2 || !(res->length()))
{