Skip to content
Permalink
Browse files
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.
  • Loading branch information
dr-m committed Sep 3, 2020
1 parent cd36bc0 commit a256070
Showing 1 changed file with 2 additions and 1 deletion.
@@ -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=

0 comments on commit a256070

Please sign in to comment.