It looks like this is a problem with OS X 10.9 Mavericks and (some?) SMB shares. There is currently no fix or workaround.
Some people have suggested connecting to the share with cifs:// instead of smb:// however this does NOT appear to solve the issue.
The issue can be reproduced as follows:
<on an SMB share>
$ echo "blah blah blah blah" > test.txt
$ more test.txt
<file is fine>
$ echo "blah" > test.txt
$ more test.txt
<file has ^@ characters at the end>
So, using the terminal, if you overwrite a file with a smaller one, then you get these NUL characters at the end. There may be other ways to cause the file to be appended or prepended with those NUL characters too.
A number of people are complaining about this, for example: https://netbeans.org/bugzilla/show_bug.cgi?id=237766
Here is the conclusion from that page:
I can replicate the null characters in Komodo Edit and Aptana Studio, so this doesn't appear to be a Netbeans specific issue, and is probably related to the NAS/SMB issue.
I forced the smb1 connection but it made no difference. Even if I eject the shares, and reconnect with cifs:// and create, modify and save a file, it's still corrupted.
It looks like Apple is going to have to resolve this, unless someone can come up with a viable workaround.
Hopefully Apple will fix this issue shortly. Until then, you could potentially use Double Commander or some other program that implements its own SMB stack.