MDEV-36245 - Long server_audit_file_path causes buffer overflow #3874
+8
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Currently, the length of the
server_audit_file_path
system variable value isnot checked. This can cause a buffer overflow if given a long file path
specifying a directory as a memcpy() is performed to copy the entire file path into a
fixed size buffer,
char alt_path_buffer[FN_REFLEN+1+DEFAULT_FILENAME_LEN];
We now add a check on the length of this value and reject the new value accordingly.
In
file_logger:logger_open()
, there is a check:As n_dig(rotations) may return up to 3, this inherently limits the file path to
at most
FN_REFLEN - 4 = 512 - 4 = 508
characters.Release Notes
Fixed buffer overflow in server_audit plugin when specifying long directory paths for
server_audit_file_path
.How can this PR be tested?
Create a directory of length > FN_REFLEN+1+DEFAULT_FILENAME_LEN = 512+1+16 = 529
Install audit plugin, enable logging, and set
server_audit_file_path
to the long directory pathBefore
After
Basing the PR against the correct MariaDB version
PR quality check
Copyright
All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.