add bounds checks. Found by Klockwork (www.klocwork.com)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8476 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2008-05-19 21:33:52 +00:00
parent 117c0315cc
commit 085088f35e
1 changed files with 4 additions and 0 deletions

View File

@ -144,6 +144,10 @@ SWITCH_DECLARE(void) switch_perform_substitution(switch_regex_t *re, int match_c
z = 0; z = 0;
num = atoi(index); num = atoi(index);
if (num < 0 || num > 256) {
num = -1;
}
if (pcre_copy_substring(field_data, ovector, match_count, num, replace, sizeof(replace)) > 0) { if (pcre_copy_substring(field_data, ovector, match_count, num, replace, sizeof(replace)) > 0) {
switch_size_t r; switch_size_t r;
for (r = 0; r < strlen(replace); r++) { for (r = 0; r < strlen(replace); r++) {