diff --git a/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta_api b/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta_api index e0416fb66c..73369c73d7 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta_api +++ b/libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta_api @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # # Run test_nta_api # diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c b/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c index 87fc11867c..c0bc8e8b80 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c @@ -1135,7 +1135,7 @@ int test_bye_after_receiving_401(struct context *ctx) INVITE(b, b_call, b_call->nh, SIPTAG_SUBJECT_STR("NUA-6.3 re-INVITE"), TAG_END()); - run_ab_until(ctx, -1, reject_reinvite_401, -1, until_final_response); + run_ab_until(ctx, -1, reject_reinvite_401, -1, save_until_final_response); TEST_1(nua_handle_has_active_call(a_call->nh)); TEST_1(nua_handle_has_active_call(b_call->nh)); @@ -1210,7 +1210,7 @@ int test_bye_after_sending_401(struct context *ctx) INVITE(b, b_call, b_call->nh, SIPTAG_SUBJECT_STR("NUA-6.4.1 re-INVITE"), TAG_END()); - run_ab_until(ctx, -1, reject_reinvite_401, -1, until_final_response); + run_ab_until(ctx, -1, reject_reinvite_401, -1, save_until_final_response); TEST_1(nua_handle_has_active_call(a_call->nh)); TEST_1(nua_handle_has_active_call(b_call->nh)); @@ -1286,7 +1286,7 @@ int test_bye_after_receiving_401_to_update(struct context *ctx) SIPTAG_SUBJECT_STR("NUA-6.4.2 UPDATE"), TAG_END()); BYE(b, b_call, b_call->nh, TAG_END()); /* Queued until nua_authenticate */ - run_ab_until(ctx, -1, reject_reinvite_401, -1, until_final_response); + run_ab_until(ctx, -1, reject_reinvite_401, -1, save_until_final_response); TEST_1(nua_handle_has_active_call(a_call->nh)); TEST_1(nua_handle_has_active_call(b_call->nh)); diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c b/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c index ec7700975c..80d3f30c41 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c @@ -55,7 +55,9 @@ int until_final_response(CONDITION_PARAMS) int save_until_final_response(CONDITION_PARAMS) { save_event_in_list(ctx, event, ep, call); - return event >= nua_r_set_params && status >= 200; + return + nua_r_set_params <= event && event < nua_i_network_changed + && status >= 200; } /** Save events. diff --git a/libs/sofia-sip/libsofia-sip-ua/sdp/torture_sdp.c b/libs/sofia-sip/libsofia-sip-ua/sdp/torture_sdp.c index 7fdb2dfa0f..53bec31325 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sdp/torture_sdp.c +++ b/libs/sofia-sip/libsofia-sip-ua/sdp/torture_sdp.c @@ -460,7 +460,7 @@ static int test_sanity(void) su_home_check(home); TEST_1(home); - TEST_1((parser = sdp_parse(home, s3_msg, sizeof(s1_msg), 0))); + TEST_1((parser = sdp_parse(home, s3_msg, sizeof(s3_msg) - 1, 0))); TEST_1(sdp_sanity_check(parser) == 0); @@ -469,6 +469,52 @@ static int test_sanity(void) END(); } +static char const pint_msg[] = + "v=0\r\n" + "o=- 2353687640 2353687640 IN IP4 128.3.4.5\r\n" + "s=marketing\r\n" + "e=john.jones.3@chinet.net\r\n" + "c= TN RFC2543 +1-201-406-4090\r\n" + "t=2353687640 0\r\n" + "m=audio 1 voice -\r\n" + ; + +static char const pint_torture_msg[] = + "v=0\r\n" + "o=- 2353687640 2353687640 IN IP4 128.3.4.5\r\n" + "s=marketing\r\n" + + "c= TN RFC2543 123\r\n" + "a=phone-context:+97252\r\n" + "t=2353687640 0\r\n" + "m= text 1 fax plain\r\n" + "a=fmtp:plain spr:fi6MeoclEjaF3EDfYHlkqx1zn8A1lMoiJFUHpQ5Xo\r\n" + ; + +static int test_pint(void) +{ + su_home_t *home = su_home_create(); + sdp_parser_t *parser; + sdp_session_t *sdp; + + BEGIN(); + + su_home_check(home); TEST_1(home); + + TEST_1((parser = sdp_parse(home, pint_msg, sizeof(pint_msg) - 1, sdp_f_anynet))); + TEST_1((sdp = sdp_session(parser))); + + TEST_1((parser = sdp_parse(home, pint_torture_msg, sizeof(pint_torture_msg) - 1, + sdp_f_anynet))); + TEST_1((sdp = sdp_session(parser))); + + su_home_check(home); + su_home_unref(home); + + END(); +} + + static sdp_list_t const l0[1] = {{ sizeof(l0), NULL, "foo" }}; static sdp_list_t const l1[1] = {{ sizeof(l1), (sdp_list_t *)l0, "bar" }}; @@ -873,6 +919,7 @@ int main(int argc, char *argv[]) retval |= test_error(); fflush(stdout); retval |= test_session(); fflush(stdout); retval |= test_session2(); fflush(stdout); + retval |= test_pint(); fflush(stdout); retval |= test_sanity(); fflush(stdout); retval |= test_list(); fflush(stdout); retval |= test_rtpmap(); fflush(stdout); diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/run_test_sip_msg b/libs/sofia-sip/libsofia-sip-ua/sip/run_test_sip_msg index 4fa9282836..7a5aeb78de 100755 --- a/libs/sofia-sip/libsofia-sip-ua/sip/run_test_sip_msg +++ b/libs/sofia-sip/libsofia-sip-ua/sip/run_test_sip_msg @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # # Run the parser tests # diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/sip_pref_util.c b/libs/sofia-sip/libsofia-sip-ua/sip/sip_pref_util.c index 43a52d4354..e36ae34542 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sip/sip_pref_util.c +++ b/libs/sofia-sip/libsofia-sip-ua/sip/sip_pref_util.c @@ -44,6 +44,8 @@ #include #include +static double parse_number(char const *str, char **return_end); + /** Parse a single preference */ int sip_prefs_parse(union sip_pref *sp, char const **in_out_s, @@ -107,16 +109,16 @@ int sip_prefs_parse(union sip_pref *sp, s0 = s[0]; if (s0 == '=') - sp->sp_type = sp_range, n1 = n2 = strtod(s = s + 1, &e); + sp->sp_type = sp_range, n1 = n2 = parse_number(s = s + 1, &e); else if (s0 == '<' && s[1] == '=') - sp->sp_type = sp_range, n1 = DBL_MIN, n2 = strtod(s = s + 2, &e); + sp->sp_type = sp_range, n1 = -DBL_MAX, n2 = parse_number(s = s + 2, &e); else if (s0 == '>' && s[1] == '=') - sp->sp_type = sp_range, n1 = strtod(s = s + 2, &e), n2 = DBL_MAX; - else if (((n1 = strtod(s, &e)) != 0.0 || s != e) && e[0] == ':') - sp->sp_type = sp_range, n2 = strtod(s = e + 1, &e); + sp->sp_type = sp_range, n1 = parse_number(s = s + 2, &e), n2 = DBL_MAX; + else if (((n1 = parse_number(s, &e)) != 0.0 || s != e) && e[0] == ':') + sp->sp_type = sp_range, n2 = parse_number(s = e + 1, &e); else /* Error in conversion */ - sp->sp_type = sp_error, n1 = DBL_MAX, n2 = DBL_MIN; + sp->sp_type = sp_error, n1 = DBL_MAX, n2 = -DBL_MAX; if (s == e && (n1 == 0.0 || n2 == 0.0)) sp->sp_type = sp_error; /* Error in conversion */ @@ -155,6 +157,46 @@ int sip_prefs_parse(union sip_pref *sp, return sp->sp_type != sp_error; } +/** Parse number: + * number = [ "+" / "-" ] 1*DIGIT ["." 0*DIGIT] + */ +static double parse_number(char const *str, char **return_end) +{ + double value = 0.0; + double decimal = 0.1; + char d, sign = '+'; + + if (return_end) + *return_end = (char *)str; + + d = *str; + + if (d == '+' || d == '-') + sign = d, d = *++str; + + if (!('0' <= d && d <= '9')) + return value; + + for (; '0' <= d && d <= '9'; d = *++str) + value = value * 10 + (d - '0'); + + if (d == '.') for (d = *++str; '0' <= d && d <= '9'; d = *++str) { + value += (d - '0') * decimal; decimal *= 0.1; + } + + if (value > DBL_MAX) + value = DBL_MAX; + + if (sign == '-') + value = -value; + + if (return_end) + *return_end = (char *)str; + + return value; +} + + /** Return true if preferences match */ int sip_prefs_match(union sip_pref const *a, union sip_pref const *b) diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_util.h b/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_util.h index ccdd72fc4d..f43c9f49a1 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_util.h +++ b/libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_util.h @@ -149,8 +149,8 @@ union sip_pref */ struct sp_range { enum sp_type spr_type; - double spr_lower; - double spr_upper; + double spr_lower; /**< Lower limit. Lowest value is -DBL_MAX. */ + double spr_upper; /**< Upper limit. Highest value is DBL_MAX. */ } sp_range; }; diff --git a/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c b/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c index 6c8c568c0a..a173c11d12 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c +++ b/libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c @@ -2535,6 +2535,7 @@ int test_request_disposition(void) } #include +#include int test_caller_prefs(void) { @@ -2650,7 +2651,7 @@ int test_caller_prefs(void) TEST_1(sip_prefs_parse(sp, &s, &negate)); TEST(sp->sp_type, sp_range); - TEST_D(sp->sp_range.spr_lower, DBL_MIN); + TEST_D(sp->sp_range.spr_lower, -DBL_MAX); TEST_D(sp->sp_range.spr_upper, 3.0); TEST_1(sip_prefs_match(sp, sp)); TEST_1(!negate); @@ -2668,7 +2669,7 @@ int test_caller_prefs(void) TEST_1(sip_prefs_parse(sp, &s, &negate)); TEST(sp->sp_type, sp_range); - TEST_D(sp->sp_range.spr_lower, DBL_MIN); + TEST_D(sp->sp_range.spr_lower, -DBL_MAX); TEST_D(sp->sp_range.spr_upper, 6.0); TEST_1(sip_prefs_match(sp, sp)); TEST_1(negate); @@ -2687,6 +2688,46 @@ int test_caller_prefs(void) TEST_1(!sip_prefs_parse(sp, &s, &negate)); TEST(sp->sp_type, sp_init); + /* Numeric */ + s = "\" !#=" + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111" + + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111." + + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111" + + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111" + "1111111111111111111111111111111111111111," + " #<=-16" + "\""; + + negate = 0; memset(sp, 0, sizeof sp); + + TEST_1(sip_prefs_parse(sp, &s, &negate)); + TEST(sp->sp_type, sp_range); + TEST_D(sp->sp_range.spr_lower, DBL_MAX); + TEST_D(sp->sp_range.spr_upper, DBL_MAX); + TEST_1(sip_prefs_match(sp, sp)); + TEST_1(negate); + + TEST_1(sip_prefs_parse(sp, &s, &negate)); + TEST(sp->sp_type, sp_range); + TEST_D(sp->sp_range.spr_lower, -DBL_MAX); + TEST_D(sp->sp_range.spr_upper, -16.0); + TEST_1(sip_prefs_match(sp, sp)); + TEST_1(!negate); + error = 12; TEST_1(sip_prefs_matching("\"INVITE,MESSAGE,SUBSCRIBE\"", diff --git a/libs/sofia-sip/libsofia-sip-ua/sresolv/run_test_sresolv b/libs/sofia-sip/libsofia-sip-ua/sresolv/run_test_sresolv index 26a1832aa0..88f7b0480c 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sresolv/run_test_sresolv +++ b/libs/sofia-sip/libsofia-sip-ua/sresolv/run_test_sresolv @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # # Run sresolv_test using our own name server # diff --git a/libs/sofia-sip/libsofia-sip-ua/su/run_test_su b/libs/sofia-sip/libsofia-sip-ua/su/run_test_su index f5b05de0c9..35cb458b42 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/run_test_su +++ b/libs/sofia-sip/libsofia-sip-ua/su/run_test_su @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh rc=0 diff --git a/libs/sofia-sip/libsofia-sip-ua/su/run_test_su_osx b/libs/sofia-sip/libsofia-sip-ua/su/run_test_su_osx index be0d8b59e3..3fa41f5da3 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/run_test_su_osx +++ b/libs/sofia-sip/libsofia-sip-ua/su/run_test_su_osx @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh rc=0