diff options
author | Ned Bass <[email protected]> | 2014-11-06 18:18:32 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2014-11-17 15:28:59 -0800 |
commit | 7b2d78a046aa4695d434478a439a9438521d73af (patch) | |
tree | 1176ac3d83fc4187a5893786f1cae8b6b30aa25e /module/unicode | |
parent | 89b1cd6581528c576bd4ff7f713f671b23b051b5 (diff) |
Fix improper null-byte termination handling
Fix a few cases where null-byte termination of strings was done
unnecessarily or incorrectly.
- The snprintf() function always produces a null-byte terminated string
for non-negative return values, so it is not necessary to write out a
null-byte as a separate step.
- Also, it is unsafe to use the return value of snprintf() as an offset
for placing a null-byte, because if the output was truncated the return
value is the number of bytes that _would_ have been written had enough
space been available. Therefore the return value may index beyond the
array boundaries.
- Finally, snprintf() accounts for the null-byte when limiting its output
size, so there is no need to pass it a size parameter that is one less
than the buffer size.
Signed-off-by: Ned Bass <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #2875
Diffstat (limited to 'module/unicode')
0 files changed, 0 insertions, 0 deletions