diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-03-07 19:17:37 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-03-10 18:21:29 +0100 |
commit | 5d40ed864eb91314c894c713cd0d3d03c62ec8c5 (patch) | |
tree | 597eab3f29343ffb834b8a9f4e5a54f4be56212d | |
parent | e0a03ca30aa6f91daf7ea519a57d85e54dc49927 (diff) | |
download | mariadb-git-5d40ed864eb91314c894c713cd0d3d03c62ec8c5.tar.gz |
MDEV-11752 Unsafe strmov - function definition in include/m_string.h
assert that strmov() cannot be used on overlapping strings.
(because strpcpy cannot)
-rw-r--r-- | dbug/dbug.c | 2 | ||||
-rw-r--r-- | include/m_string.h | 2 | ||||
-rw-r--r-- | strings/strmov.c | 1 |
3 files changed, 4 insertions, 1 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c index b2b298beb09..3035895648e 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -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) { diff --git a/include/m_string.h b/include/m_string.h index 969725e4631..7437ea8b7cd 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -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[]; diff --git a/strings/strmov.c b/strings/strmov.c index b38d5db5d6e..0f594185688 100644 --- a/strings/strmov.c +++ b/strings/strmov.c @@ -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; } |