Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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/20696643/how-do-i-keep-nul-bytes-from-appeari ng-throughout-my-git-repository-and-commit-m

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?

Posted on Jan 16, 2014 8:42 AM

Reply
7 replies

Jan 16, 2014 10:02 AM in response to Jakobud

Apple doesn’t routinely monitor the discussions.


Send Apple feedback. They won't answer, but at least will know there is a problem. If enough people send feedback, it may get the problem solved sooner.


Feedback


Or you can use your Apple ID to register with this site and go the Apple BugReporter. Supposedly you will get an answer if you submit feedback.


Feedback via Apple Developer

Feb 13, 2014 1:59 PM in response to LaughingElephant

I have also submitted a bug report however it was rejected because it was a clone of another bug report. So someone had already submitted it apparently. It referenced a link to the other bug on the developer bug reporting site, but when I clicked it I did not have access to view it. So I have no way of knowing exactly what the status of the bug is etc. Hopefully its fixed in a Mavericks update soon.

May 6, 2014 9:18 AM in response to Jakobud

I'm having the same problem. Using a git repository in an SMB share this is very annoying.

What I've found trying the exampe is that the test.txt file is correctly written on the share, if I open it using an editor on the server there are no NULLs at the end, it's just the cached copy in memory that is corrupted.

If I unmont and then remount the share the files are correct. Unmounting and remounting let me do some commits that were impossible to do.

Bug: NULL bytes being written to file on SMB volumes

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.