[asterisk-bugs] [JIRA] (ASTERISK-23546) CB_ADD_LEN does not do what you'd think

Walter Doekes (JIRA) noreply at issues.asterisk.org
Thu Apr 3 02:00:18 CDT 2014


    [ https://issues.asterisk.org/jira/browse/ASTERISK-23546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=216998#comment-216998 ] 

Walter Doekes commented on ASTERISK-23546:
------------------------------------------

Well.. there is only one place that it is used.
{noformat}
asterisk-1.8.x-WRITE$ wgrep . CB_ADD_LEN
./main/config.c:static void  CB_ADD_LEN(struct ast_str **cb, const char *str, int len)
./main/config.c:									CB_ADD_LEN(&comment_buffer, oldptr+1, new_buf-oldptr-1);
{noformat}

And then there is the time machine in {{utils/extconf.c}}, which shows what it should do when it still worked:
{noformat}
./utils/extconf.c:static void  CB_ADD_LEN(char *str, int len)
./utils/extconf.c:									CB_ADD_LEN(oldptr+1,new_buf-oldptr-1);
{noformat}

Apparently the main/config version can be safely replaced with CB_ADD, since that has been real behaviour for a while.
{noformat}
static void  CB_ADD(struct ast_str **cb, const char *str)
{
        ast_str_append(cb, 0, "%s", str);
}
{noformat}

Option A: remove CB_ADD_LEN and pretend it never existed.
Option B: find out why no one has noticed that it was broken and fix and check that it doesn't cause regressions for anyone.

> CB_ADD_LEN does not do what you'd think
> ---------------------------------------
>
>                 Key: ASTERISK-23546
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-23546
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>    Affects Versions: SVN, 1.8.26.1
>            Reporter: Walter Doekes
>            Assignee: Walter Doekes
>            Severity: Trivial
>
> What's wrong with this code? ;)
> {code}
> static void  CB_ADD_LEN(struct ast_str **cb, const char *str, int len)
> {
>         char *s = ast_alloca(len + 1);
>         ast_copy_string(s, str, len);
>         ast_str_append(cb, 0, "%s", str);
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list