]> git.ipfire.org Git - thirdparty/freeswitch.git/commit
--resolve FS-5566
authorKen Rice <krice@freeswitch.org>
Mon, 1 Jul 2013 22:03:00 +0000 (17:03 -0500)
committerKen Rice <krice@freeswitch.org>
Mon, 1 Jul 2013 22:05:07 +0000 (17:05 -0500)
commitc2c8fba14a0352dfeecf31a0f818d83f83a93a85
treefbacc3925b938fde46a2b2c9f896e66645a8af1b
parent8bcff4ca4d3643518f98d01f52772cf71661699f
--resolve FS-5566

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>
src/switch_regex.c