miniupnpd/options.c: fix potential end of array access

This commit is contained in:
Thomas Bernard 2014-04-20 18:10:44 +02:00
parent 415d14fbe9
commit 1ff20069a1
1 changed files with 4 additions and 2 deletions

View File

@ -140,8 +140,10 @@ readoptionsfile(const char * fname)
/* check for comments or empty lines */ /* check for comments or empty lines */
if(name[0] == '#' || name[0] == '\0') continue; if(name[0] == '#' || name[0] == '\0') continue;
len = strlen(name); /* length of the whole line excluding leading
* and ending white spaces */
/* check for UPnP permissions rule */ /* check for UPnP permissions rule */
if(0 == memcmp(name, "allow", 5) || 0 == memcmp(name, "deny", 4)) if((len > 6) && (0 == memcmp(name, "allow", 5) || 0 == memcmp(name, "deny", 4)))
{ {
tmp = realloc(upnppermlist, sizeof(struct upnpperm) * (num_upnpperm+1)); tmp = realloc(upnppermlist, sizeof(struct upnpperm) * (num_upnpperm+1));
if(tmp == NULL) if(tmp == NULL)
@ -167,7 +169,7 @@ readoptionsfile(const char * fname)
} }
#ifdef PCP_SADSCP #ifdef PCP_SADSCP
/* check for DSCP values configuration */ /* check for DSCP values configuration */
if(0 == memcmp(name, "set_learn_dscp", sizeof("set_learn_dscp")-1) ) if((len > 15) && 0 == memcmp(name, "set_learn_dscp", sizeof("set_learn_dscp")-1) )
{ {
tmp = realloc(dscp_values_list, sizeof(struct dscp_values) * (num_dscp_values+1)); tmp = realloc(dscp_values_list, sizeof(struct dscp_values) * (num_dscp_values+1));
if(tmp == NULL) if(tmp == NULL)