If a existing file is opened with overwriting mode e.g. fopen(file, "w+"), the file size will be incorrect after writing any data to the file. This bug is caused by previous commit 10903b5, and its changes should be limited to only O_APPEND mode.