summaryrefslogtreecommitdiff
path: root/mysys/mf_pack.c
diff options
context:
space:
mode:
authorGeorgi Kodinov <joro@sun.com>2010-03-23 16:54:16 +0200
committerGeorgi Kodinov <joro@sun.com>2010-03-23 16:54:16 +0200
commitd95bed0215a81ec233f031f2db6d183fde3fe67b (patch)
tree917925a7b95a99bc456f47e6490dcc8074157e0a /mysys/mf_pack.c
parent6a498b59985baa6a1765c44ad267ae66b960dc12 (diff)
downloadmariadb-git-d95bed0215a81ec233f031f2db6d183fde3fe67b.tar.gz
Bug #51893: crash with certain characters given to load_file
function on windows When making sure that the directory path ends up with a slash/backslash we need to check for the correct length of the buffer and trim at the appropriate location so we don't write past the end of the buffer.
Diffstat (limited to 'mysys/mf_pack.c')
-rw-r--r--mysys/mf_pack.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c
index c13a5581b80..4f7cd90e8aa 100644
--- a/mysys/mf_pack.c
+++ b/mysys/mf_pack.c
@@ -311,6 +311,9 @@ size_t normalize_dirname(char *to, const char *from)
#endif
buff[length - 1] != FN_LIBCHAR && buff[length - 1] != '/')
{
+ /* we need reserve 2 bytes for the trailing slash and the zero */
+ if (length >= sizeof (buff) - 1)
+ length= sizeof (buff) - 2;
buff[length]= FN_LIBCHAR;
buff[length + 1]= '\0';
}