[Asterisk-code-review] pbx_functions.c: Fix buggy ast_str_strlen. (asterisk[master])

N A asteriskteam at digium.com
Sat Jul 23 17:26:29 CDT 2022


N A has uploaded a new patch set (#2). ( https://gerrit.asterisk.org/c/asterisk/+/18833 )

Change subject: pbx_functions.c: Fix buggy ast_str_strlen.
......................................................................

pbx_functions.c: Fix buggy 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
---
M main/pbx_functions.c
M main/pbx_variables.c
2 files changed, 74 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/33/18833/2
-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18833
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I4e2dba41410f9d4dff61c995d2ca27718248e07f
Gerrit-Change-Number: 18833
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-CC: Friendly Automation
Gerrit-MessageType: newpatchset
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220723/e3e59113/attachment.html>


More information about the asterisk-code-review mailing list