Commit 5f5ffdc7 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-14132 follow-up fix: Validate the posix_fallocate() argument

os_file_set_size(): Sometimes the file already is large enough.
Avoid calling posix_fallocate() with a non-positive argument.
Also, add a missing space to an error message.
parent 057a6cf7
......@@ -5382,14 +5382,16 @@ os_file_set_size(
int err;
do {
os_offset_t current_size = os_file_get_size(file);
err = posix_fallocate(file, current_size, size - current_size);
err = current_size >= size
? 0 : posix_fallocate(file, current_size,
size - current_size);
} while (err == EINTR
&& srv_shutdown_state == SRV_SHUTDOWN_NONE);
if (err) {
ib::error() <<
"preallocating " << size << " bytes for" <<
"file " << name << "failed with error " << err;
"file " << name << " failed with error " << err;
}
errno = err;
return(!err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment