diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-04-04 19:19:26 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-04-04 19:19:26 +0200 |
commit | 4c9557ef24f267ad0912f1bff6b0fdcb52c74e68 (patch) | |
tree | 339fcec4f5244553b740add467333a9300d023b7 /openbsc/tests | |
parent | 13673749ffdd8947af5ff69e477f9144e8afc57f (diff) |
nat: Bail out if the regexp fails to compile and avoid a crash
If the regexp fails to compile the internal dfa is NULL and a
regexec will crash nicely. Fail and free the string if the regexp
fails to compile.
Diffstat (limited to 'openbsc/tests')
-rw-r--r-- | openbsc/tests/bsc-nat/bsc_nat_test.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c index f5de953f1..50da1e904 100644 --- a/openbsc/tests/bsc-nat/bsc_nat_test.c +++ b/openbsc/tests/bsc-nat/bsc_nat_test.c @@ -761,15 +761,18 @@ static void test_cr_filter() nat_lst = bsc_nat_acc_lst_get(nat, "nat"); bsc_lst = bsc_nat_acc_lst_get(nat, "bsc"); - bsc_parse_reg(nat_entry, &nat_entry->imsi_deny_re, &nat_entry->imsi_deny, + if (bsc_parse_reg(nat_entry, &nat_entry->imsi_deny_re, &nat_entry->imsi_deny, cr_filter[i].nat_imsi_deny ? 1 : 0, - &cr_filter[i].nat_imsi_deny); - bsc_parse_reg(bsc_entry, &bsc_entry->imsi_allow_re, &bsc_entry->imsi_allow, + &cr_filter[i].nat_imsi_deny) != 0) + abort(); + if (bsc_parse_reg(bsc_entry, &bsc_entry->imsi_allow_re, &bsc_entry->imsi_allow, cr_filter[i].bsc_imsi_allow ? 1 : 0, - &cr_filter[i].bsc_imsi_allow); - bsc_parse_reg(bsc_entry, &bsc_entry->imsi_deny_re, &bsc_entry->imsi_deny, + &cr_filter[i].bsc_imsi_allow) != 0) + abort(); + if (bsc_parse_reg(bsc_entry, &bsc_entry->imsi_deny_re, &bsc_entry->imsi_deny, cr_filter[i].bsc_imsi_deny ? 1 : 0, - &cr_filter[i].bsc_imsi_deny); + &cr_filter[i].bsc_imsi_deny) != 0) + abort(); parsed = bsc_nat_parse(msg); if (!parsed) { |