1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-02 14:22:51 +03:00

MDEV-34205: ASAN stack buffer overflow in strxnmov() in frm_file_exists

Correct the second parameter for strxnmov to prevent potential buffer
overflows. The second parameter must be one less than the size of the
input buffer to avoid writing past the end of the buffer.

While the second parameter is usually correct, there are exceptions
that need fixing.

This commit addresses the issue within frm_file_exists() and other
affected places.
This commit is contained in:
Vladislav Vaintroub
2024-05-21 16:03:13 +02:00
parent 7c4c082349
commit 736449d30f
7 changed files with 16 additions and 5 deletions

View File

@ -1906,7 +1906,7 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
*/
build_table_filename(path, sizeof(path) - 1, lpt->alter_info->db.str,
lpt->alter_info->table_name.str, "", 0);
strxnmov(frm_name, sizeof(frm_name), path, reg_ext, NullS);
strxnmov(frm_name, sizeof(frm_name)-1, path, reg_ext, NullS);
/*
When we are changing to use new frm file we need to ensure that we
don't collide with another thread in process to open the frm file.