mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
--- !ditz.rubyforge.org,2008-03-06/issue
|
|
title: cleanup snprintf() convention
|
|
desc: |-
|
|
There seem to be to variants of snprintf (and its friends): some ensure a
|
|
NUL terminator is added when truncated and others do not.
|
|
|
|
The most portable way seems to be to::
|
|
|
|
char buf[256];
|
|
|
|
snprintf(buf, sizeof(buf), "format", args);
|
|
buf[sizeof(buf) - 1] = (char) 0;
|
|
|
|
Using sizeof(buf) - 1 for size may cause a NUL terminator to appear at
|
|
the second to last character of buf in some cases.
|
|
|
|
Document in code-issues.txt.
|
|
type: :task
|
|
component: duk
|
|
release: v0.8
|
|
reporter: sva <sami.vaarala@iki.fi>
|
|
status: :unstarted
|
|
disposition:
|
|
creation_time: 2013-09-19 07:09:07.951148 Z
|
|
references: []
|
|
|
|
id: ee19ffa04904f297e2ac4957a4cd442c9a0e0c2b
|
|
log_events:
|
|
- - 2013-09-19 07:09:08.132219 Z
|
|
- sva <sami.vaarala@iki.fi>
|
|
- created
|
|
- ""
|
|
- - 2013-09-19 07:12:50.251175 Z
|
|
- sva <sami.vaarala@iki.fi>
|
|
- commented
|
|
- |-
|
|
Also the return value of snprintf (and its friends) seems to vary between
|
|
implementations when the string is truncated. This is mostly the case with
|
|
old environments. Document that snprintf return value is not to be trusted
|
|
without care.
|
|
|