summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-09-03 08:41:47 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-09-03 08:41:47 +0300
commita256070e7d94fdd1d63a4823c638ff5c76ca9c73 (patch)
treeadb07b5d0224c94ed91a9048d0b450f80e996c66
parentcd36bc01a5f1c1cd126cdd0668c6049cc78be40a (diff)
downloadmariadb-git-a256070e7d94fdd1d63a4823c638ff5c76ca9c73.tar.gz
MDEV-7110 follow-up fix: Do not pass NULL as nonnull parameter
Passing a null pointer to the "%s" argument of a printf-like function is undefined behaviour. In the GNU libc implementation of the printf() family of functions, it happens to work. GCC 10.2.0 would diagnose this with -Wformat-overflow -Og. In -fsanitize=undefined (WITH_UBSAN=ON) builds, a runtime error would be generated. In some other builds, GCC 8 or later might infer that the parameter is nonnull and optimize away further checks whether the parameter is null, leading to SIGSEGV.
-rw-r--r--sql/mysqld.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 6a5162e2f03..8d00b5af948 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3974,7 +3974,8 @@ rpl_make_log_name(const char *opt,
const char *ext)
{
DBUG_ENTER("rpl_make_log_name");
- DBUG_PRINT("enter", ("opt: %s, def: %s, ext: %s", opt, def, ext));
+ DBUG_PRINT("enter", ("opt: %s, def: %s, ext: %s", opt ? opt : "(null)",
+ def, ext));
char buff[FN_REFLEN];
const char *base= opt ? opt : def;
unsigned int options=