about summary refs log tree commit diff
path: root/include/link.h
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2016-10-21 20:57:15 -0400
committerRich Felker <dalias@aerifal.cx>2016-10-21 22:15:31 -0400
commited8696742504b6182954254e78ec123c8bcd8d3b (patch)
treec48f0867c50e5c1ef2b0104d3d63d675fa29c22c /include/link.h
parent7597fc25a2743d49500926a286da71f8e033936c (diff)
downloadmusl-ed8696742504b6182954254e78ec123c8bcd8d3b.tar.gz
musl-ed8696742504b6182954254e78ec123c8bcd8d3b.tar.xz
musl-ed8696742504b6182954254e78ec123c8bcd8d3b.zip
redesign snprintf without undefined behavior
the old snprintf design setup the FILE buffer pointers to point
directly into the destination buffer; if n was actually larger than
the buffer size, the pointer arithmetic to compute the buffer end
pointer was undefined. this affected sprintf, which is implemented in
terms of snprintf, as well as some unusual but valid direct uses of
snprintf.

instead, setup the FILE as unbuffered and have its write function
memcpy to the destination. the printf core sets up its own temporary
buffer for unbuffered streams.
Diffstat (limited to 'include/link.h')
0 files changed, 0 insertions, 0 deletions