Review Board 1.7.16


chan_sip: [general] maxforwards, not checked for a value greater than 255

Review Request #1888 - Created April 25, 2012 and submitted

Alec Davis
1.8 and above
Reviewers
asterisk-dev
Asterisk
The peer maxforwards is checked for both '< 1' and '> 255',
but the default 'maxforwards' in the [general] section is only checked for '< 1'.

Pet hate: if a number is always 0 or positive, decleare it 'unsigned':
thus 'maxforwards' should be declared 'unsigned int' not 'int', and use '%30u' instead '%30d' with sscanf.

 

Diff revision 1 (Latest)

  1. trunk/channels/chan_sip.c: Loading...
trunk/channels/chan_sip.c
Revision 361088 New Change
[20] 29812 lines
[+20] [+] static int reload_config(enum channelreloadreason reason)
29813
				ast_log(LOG_WARNING, "shrinkcallerid value %s is not valid at line %d.\n", v->value, v->lineno);
29813
				ast_log(LOG_WARNING, "shrinkcallerid value %s is not valid at line %d.\n", v->value, v->lineno);
29814
			}
29814
			}
29815
		} else if (!strcasecmp(v->name, "use_q850_reason")) {
29815
		} else if (!strcasecmp(v->name, "use_q850_reason")) {
29816
			ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_Q850_REASON);
29816
			ast_set2_flag(&global_flags[1], ast_true(v->value), SIP_PAGE2_Q850_REASON);
29817
		} else if (!strcasecmp(v->name, "maxforwards")) {
29817
		} else if (!strcasecmp(v->name, "maxforwards")) {
29818
			if ((sscanf(v->value, "%30d", &sip_cfg.default_max_forwards) != 1) || (sip_cfg.default_max_forwards < 1)) {
29818
			if (sscanf(v->value, "%30d", &sip_cfg.default_max_forwards) != 1

    
   
29819
				|| sip_cfg.default_max_forwards < 1 || 255 < sip_cfg.default_max_forwards) {
29819
				ast_log(LOG_WARNING, "'%s' is not a valid maxforwards value at line %d.  Using default.\n", v->value, v->lineno);
29820
				ast_log(LOG_WARNING, "'%s' is not a valid maxforwards value at line %d.  Using default.\n", v->value, v->lineno);
29820
				sip_cfg.default_max_forwards = DEFAULT_MAX_FORWARDS;
29821
				sip_cfg.default_max_forwards = DEFAULT_MAX_FORWARDS;
29821
			}
29822
			}
29822
		} else if (!strcasecmp(v->name, "subscribe_network_change_event")) {
29823
		} else if (!strcasecmp(v->name, "subscribe_network_change_event")) {
29823
			if (ast_true(v->value)) {
29824
			if (ast_true(v->value)) {
[+20] [20] 2008 lines
  1. trunk/channels/chan_sip.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.