]> git.ipfire.org Git - thirdparty/asterisk.git/commit
pbx_functions.c: Manually update ast_str strlen.
authorNaveen Albert <asterisk@phreaknet.org>
Sat, 23 Jul 2022 22:17:28 +0000 (22:17 +0000)
committerN A <mail@interlinked.x10host.com>
Tue, 26 Jul 2022 15:48:10 +0000 (10:48 -0500)
commita2799554d25d74eeb5dfb8bc8e52887fb27637fb
tree5d160b21d6ba37b0b4a06375f919a6e98a09dbef
parent133ecb346c36857c5e8ecc61dc4b70e51ff2a1a0
pbx_functions.c: Manually update ast_str strlen.

When ast_func_read2 is used to read a function using
its read function (as opposed to a native ast_str read2
function), the result is copied directly by the function
into the ast_str buffer. As a result, the ast_str length
remains initialized to 0, which is a bug because this is
not the real string length.

This can cascade and have issues elsewhere, such as when
reading substrings of functions that only register read
as opposed to read2 callbacks. In this case, since reading
ast_str_strlen returns 0, the returned substring is empty
as opposed to the actual substring. This has caused
the ast_str family of functions to behave inconsistently
and erroneously, in contrast to the pbx_variables substitution
functions which work correctly.

This fixes this issue by manually updating the ast_str length
when the result is copied directly into the ast_str buffer.

Additionally, an assertion and a unit test that previously
exposed these issues are added, now that the issue is fixed.

ASTERISK-29966 #close

Change-Id: I4e2dba41410f9d4dff61c995d2ca27718248e07f
main/pbx_functions.c
main/pbx_variables.c