Bug: NULL bytes being written to file on SMB volumes
This is a 100% reproducable bug.
When writing to files that are on a Samba (SMB) volume, if you are overwriting a file and making it smaller than it previously was, then OSX is writing NULL bytes to the end fo the file, which produce all sorts of problems, especially for software developers.
How to reproduce:
Open Terminal, navigate to a SMB volume and do the following:
# echo "test" > test.txt
# more test.txt
test
# echo "test test test test" > test.txt
# more test.txt
test test test test
# echo "test" > test.txt
# more test.txt
"test.txt" may be a binary file. See it anyway?
test
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
This is 100% reproducable every time. As you can see, when you overwrite a file with a larger version, the NULL bytes are not written to the file. But when you overwrite with a smaller version, NULL bytes are written to the end of the file.
This problem is especially a problem for developers. I came across this bug because I had a git repository on an SMB share/volume. Whenever I would try to commit changes to the repository, if the git commit log file was shorter than it was in the previous commit, then git threw the error:
error: a NULL byte in commit log message not allowed.
fatal: failed to write commit object
You can see this issue being discussed and reported in several places:
http://stackoverflow.com/questions/19705825/error-a-nul-byte-in-commit-log-messa ge-not-allowed
https://netbeans.org/bugzilla/show_bug.cgi?id=237766
This bug was introduced in Mavericks. Also, remounting the volume using cifs:// doesn't make a difference.
Does anyone have any solutions for this problem? Has this been reported to Apple? Does Apple know about this problem?