The original client code would only write the trailing nul character when the copied string had a non-zero length. Furthermore, the DirtSand code could attempt to write the trailing nul outside the buffer, which is dangerous! This fixes both issues by only writing the trailing nul when the strings are non-empty.
The original client code would only write the trailing nul character when the copied string had a non-zero length. Furthermore, the DirtSand code could attempt to write the trailing nul outside the buffer, which is dangerous! This fixes both issues by only writing the trailing nul when the strings are non-empty.