• Ken Rice's avatar
    --resolve FS-5566 · c2c8fba1
    Ken Rice 提交于
    When you use $12345 in regex substitutions, it isn't obvious
    whenever you mean $1-concatenated-2345 or $12-concatenated-345
    or any other variation.  In all other languages, in order to
    solve this ambiguity, a braces {} are allowed to be used to
    separate variable name (or a reference) from surrounding text,
    like ${1}2345 or ${12}345.  Use the same for freeswitch too.
    
    While at it, fix a buffer overflow as well: the index[] variable
    which is used to copy the "variable" name is 10 chars long, but
    it is used in the code without bounds checking, so a reference
    which is >9 chars long ($1234567890) will overflow the buffer,
    crashing freeswitch.
    
    And another overflow is in the way how size of the "substituted"
    variable is handled.  First, in the outer loop, we compare the
    wrong variable with the size of `substituted' buffer (amount of
    bytes we took from the source instead of amount of bytes we
    used in `substituted').  And second, when actual regex match
    is being substitured, amount of room in `substituted' variable
    is not checked at all.
    
    Patch contributed by Michael Tokarev <mjt@tls.msk.ru>
    c2c8fba1
switch_regex.c 7.9 KB