Commit c9207f7f authored by Olov Lassus's avatar Olov Lassus Committed by Bert Belder
Browse files

fs: fix corruption in writeFile and writeFileSync

1. writeFileSync bumps position incorrectly, causing it to drift in
iteration three and onwards.

2. Append mode files will get corrupted in the middle if writeFile or
writeFileSync iterates multiple times, unless running on Linux. position
starts out as null so first write is OK, but then position will refer to
a location inside an existing file, corrupting that data. Linux ignores
position for append mode files so it doesn't happen there.

This commit fixes these two related issues by bumping position correctly
and by always using null as the position argument to write/writeSync for
append mode files.

PR-URL: https://github.com/iojs/io.js/pull/1063


Reviewed-By: default avatarBert Belder <bertbelder@gmail.com>
parent 4e9bf93e
Supports Markdown
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