]> git.ipfire.org Git - thirdparty/asterisk.git/commit
pbx.c: Fix crash from malformed exten pattern.
authorRichard Mudgett <rmudgett@digium.com>
Tue, 14 Mar 2017 21:16:23 +0000 (16:16 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 14 Mar 2017 23:08:02 +0000 (18:08 -0500)
commit9fd9b39e8bba8471d1564e24f048d99e41fc41e1
tree71c515d527f6d973a69d96a6646c740fd9985c57
parent071e6d971cb97df767b2c6c4c1fdcac17bf92038
pbx.c: Fix crash from malformed exten pattern.

Forgetting to indicate an exten is a pattern can cause a crash if the
"pattern" has a character set range.  e.g., "9999[3-5]" The crash is due
to a buffer overwrite because the '-' exten eye-candy wasn't removed as
expected and overran the allocated space.

The buffer overwrite is fixed two ways in this patch.

1) Fix ext_strncpy() to distinguish between pattern and non-pattern
extens.  Now '-' characters are removed when they are eye-candy and not
when they are part of a pattern character set.  Since the function is
private to pbx.c, the return value now returns the number of bytes written
to the destination buffer instead of the strlen() of the final buffer so
the callers that care don't need to add one.

2) Fix callers to ext_strncpy() to supply the correct available buffer
size of the destination buffer.

ASTERISK-26668

Change-Id: I555d97411140e47e0522684062d174fbe32aa84a
main/pbx.c