diff options
author | unknown <marko@hundin.mysql.fi> | 2005-06-27 17:25:37 +0300 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2005-06-27 17:25:37 +0300 |
commit | b608f091dbf628db32e67e9a62f3045f6dcf2ed7 (patch) | |
tree | 292da2eae748876d3076518a9958c2e25f2ab174 /innobase | |
parent | 1084e540ee034ec2dda0645ea9fd78a13a231cbd (diff) | |
download | mariadb-git-b608f091dbf628db32e67e9a62f3045f6dcf2ed7.tar.gz |
InnoDB: After review fixes
innobase/os/os0file.c:
os_file_set_size(): After review fixes (prevent overflows)
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/os/os0file.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 25123c47cb8..4313b7f7019 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -1668,7 +1668,8 @@ os_file_set_size( desired_size = (ib_longlong)size + (((ib_longlong)size_high) << 32); /* Write up to 1 megabyte at a time. */ - buf_size = ut_min(UNIV_PAGE_SIZE * 64, desired_size); + buf_size = ut_min(64, (ulint) (desired_size / UNIV_PAGE_SIZE)) + * UNIV_PAGE_SIZE; buf2 = ut_malloc(buf_size + UNIV_PAGE_SIZE); /* Align the buffer for possible raw i/o */ @@ -1683,8 +1684,14 @@ os_file_set_size( } while (current_size < desired_size) { - ulint n_bytes = ut_min(buf_size, - (ulint) (desired_size - current_size)); + ulint n_bytes; + + if (desired_size - current_size < (ib_longlong) buf_size) { + n_bytes = (ulint) (desired_size - current_size); + } else { + n_bytes = buf_size; + } + ret = os_file_write(name, file, buf, (ulint)(current_size & 0xFFFFFFFF), (ulint)(current_size >> 32), |