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

assert that strmov() cannot be used on overlapping strings.
(because strpcpy cannot)
This commit is contained in:
Sergei Golubchik 2017-03-07 19:17:37 +01:00
parent e0a03ca30a
commit 5d40ed864e
3 changed files with 4 additions and 1 deletions

View file

@ -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)
{

View file

@ -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[];

View file

@ -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;
}