Commit 5d40ed86 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-11752 Unsafe strmov - function definition in include/m_string.h

assert that strmov() cannot be used on overlapping strings.
(because strpcpy cannot)
parent e0a03ca3
......@@ -1883,7 +1883,7 @@ static void DBUGOpenFile(CODE_STATE *cs,
cs->stack->name[len]=0;
}
else
strmov(cs->stack->name,name);
strmov(cs->stack->name,name);
name=cs->stack->name;
if (strcmp(name, "-") == 0)
{
......
......@@ -73,11 +73,13 @@ extern void *(*my_str_malloc)(size_t);
extern void *(*my_str_realloc)(void *, size_t);
extern void (*my_str_free)(void *);
#ifdef DBUG_OFF
#if defined(HAVE_STPCPY) && MY_GNUC_PREREQ(3, 4) && !defined(__INTEL_COMPILER)
#define strmov(A,B) __builtin_stpcpy((A),(B))
#elif defined(HAVE_STPCPY)
#define strmov(A,B) stpcpy((A),(B))
#endif
#endif
/* Declared in int2str() */
extern const char _dig_vec_upper[];
......
......@@ -40,6 +40,7 @@
char *strmov(register char *dst, register const char *src)
{
DBUG_ASSERT(src + strlen(src) < dst || dst + strlen(src) < src);
while ((*dst++ = *src++)) ;
return dst-1;
}
......
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