]> git.ipfire.org Git - thirdparty/asterisk.git/commit
Iostreams: Correct off-by-one error. 56/4556/2
authorMark Michelson <mmichelson@digium.com>
Tue, 6 Dec 2016 16:56:06 +0000 (10:56 -0600)
committerMark Michelson <mmichelson@digium.com>
Tue, 6 Dec 2016 18:34:51 +0000 (12:34 -0600)
commitbf6423a33678d95896cfb6325572dab3a23e6d6a
treed8c231d31b6372b896096f60d17da35e7e915043
parent68fc035795f1fa61a6da3800266b67fd123bc5bd
Iostreams: Correct off-by-one error.

ast_iostream_printf() attempts first to use a fixed-size buffer to
perform its printf-like operation. If the fixed-size buffer is too
small, then a heap allocation is used instead. The heap allocation in
this case was exactly the length of the string to print. The issue here
is that the ensuing call to vsnprintf() will print a NULL byte in the
final space of the string. This meant that the final character was being
chopped off the string and replaced with a NULL byte. For HTTP in
particular, this caused problems because HTTP publishes the expected
Contact-Length. This meant HTTP was publishing a length one character
larger than what was actually present in the message.

This patch corrects the issue by adding one to the allocation length.

ASTERISK-26629
Reported by Joshua Colp

Change-Id: Ib3c5f41e96833d0415cf000656ac368168add639
main/iostream.c