mirror of
https://github.com/MariaDB/server.git
synced 2026-04-26 02:05:31 +02:00
InnoDB: Fix potential buffer underflow.
innobase/include/ut0mem.h: Add ut_strlcpy_rev. innobase/mem/mem0mem.c: Use ut_strlcpy_rev instead of buggy own implementation. innobase/ut/ut0mem.c: Add ut_strlcpy_rev.
This commit is contained in:
parent
a5dd3d5d8f
commit
b2d8eb02a7
3 changed files with 38 additions and 4 deletions
|
|
@ -122,6 +122,7 @@ ut_strcmp(const void* str1, const void* str2);
|
|||
Copies up to size - 1 characters from the NUL-terminated string src to
|
||||
dst, NUL-terminating the result. Returns strlen(src), so truncation
|
||||
occurred if the return value >= size. */
|
||||
|
||||
ulint
|
||||
ut_strlcpy(
|
||||
/*=======*/
|
||||
|
|
@ -130,6 +131,18 @@ ut_strlcpy(
|
|||
const char* src, /* in: source buffer */
|
||||
ulint size); /* in: size of destination buffer */
|
||||
|
||||
/**************************************************************************
|
||||
Like ut_strlcpy, but if src doesn't fit in dst completely, copies the last
|
||||
(size - 1) bytes of src, not the first. */
|
||||
|
||||
ulint
|
||||
ut_strlcpy_rev(
|
||||
/*===========*/
|
||||
/* out: strlen(src) */
|
||||
char* dst, /* in: destination buffer */
|
||||
const char* src, /* in: source buffer */
|
||||
ulint size); /* in: size of destination buffer */
|
||||
|
||||
/**************************************************************************
|
||||
Compute strlen(ut_strcpyq(str, q)). */
|
||||
UNIV_INLINE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue