slightly restructure a block to reduce nesting,
mark some missing error checks git-svn-id: http://svn.digium.com/svn/asterisk/trunk@22957 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
87ae24bd3d
commit
1fae650d42
|
@ -318,30 +318,32 @@ includes { STORE_POS; return KW_INCLUDES;}
|
|||
\#include[ \t]+\"[^\"]+\" {
|
||||
FILE *in1;
|
||||
char fnamebuf[1024],*p1,*p2;
|
||||
if ( include_stack_index >= MAX_INCLUDE_DEPTH ) {
|
||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Includes nested too deeply! Wow!!! How did you do that?\n", my_file, my_lineno, my_col);
|
||||
} else {
|
||||
int error = 1; /* don't use the file if set */
|
||||
p1 = strchr(yytext,'"');
|
||||
p2 = strrchr(yytext,'"');
|
||||
if ( (int)(p2-p1) > 1023 ) {
|
||||
if ( include_stack_index >= MAX_INCLUDE_DEPTH ) {
|
||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Includes nested too deeply! Wow!!! How did you do that?\n", my_file, my_lineno, my_col);
|
||||
} else if ( (int)(p2-p1) > sizeof(fnamebuf) - 1 ) {
|
||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Filename is incredibly way too long (%d chars!). Inclusion ignored!\n", my_file, my_lineno, my_col, yyleng - 10);
|
||||
} else {
|
||||
int i;
|
||||
int found = 0;
|
||||
strncpy(fnamebuf, p1, p2-p1);
|
||||
fnamebuf[p2-p1] = 0;
|
||||
for (i=0; i<include_stack_index; i++) {
|
||||
if ( !strcmp(fnamebuf,include_stack[i].fname )) {
|
||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Nice Try!!! But %s has already been included (perhaps by another file), and would cause an infinite loop of file inclusions!!! Include directive ignored\n",
|
||||
my_file, my_lineno, my_col, fnamebuf);
|
||||
found=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !found ) {
|
||||
if (i == include_stack_index)
|
||||
error = 0; /* we can use this file */
|
||||
}
|
||||
if ( !error ) { /* valid file name */
|
||||
*p2 = 0;
|
||||
/* relative vs. absolute */
|
||||
if ( *(p1+1) != '/' ) {
|
||||
/* XXX must check overflows */
|
||||
strcpy(fnamebuf,ast_config_AST_CONFIG_DIR);
|
||||
strcat(fnamebuf,"/");
|
||||
strcat(fnamebuf,p1+1);
|
||||
|
@ -374,8 +376,6 @@ includes { STORE_POS; return KW_INCLUDES;}
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<<EOF>> {
|
||||
if ( --include_stack_index < 0 ) {
|
||||
|
|
|
@ -1470,30 +1470,32 @@ YY_RULE_SETUP
|
|||
{
|
||||
FILE *in1;
|
||||
char fnamebuf[1024],*p1,*p2;
|
||||
if ( include_stack_index >= MAX_INCLUDE_DEPTH ) {
|
||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Includes nested too deeply! Wow!!! How did you do that?\n", my_file, my_lineno, my_col);
|
||||
} else {
|
||||
int error = 1; /* don't use the file if set */
|
||||
p1 = strchr(yytext,'"');
|
||||
p2 = strrchr(yytext,'"');
|
||||
if ( (int)(p2-p1) > 1023 ) {
|
||||
if ( include_stack_index >= MAX_INCLUDE_DEPTH ) {
|
||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Includes nested too deeply! Wow!!! How did you do that?\n", my_file, my_lineno, my_col);
|
||||
} else if ( (int)(p2-p1) > sizeof(fnamebuf) - 1 ) {
|
||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Filename is incredibly way too long (%d chars!). Inclusion ignored!\n", my_file, my_lineno, my_col, yyleng - 10);
|
||||
} else {
|
||||
int i;
|
||||
int found = 0;
|
||||
strncpy(fnamebuf, p1, p2-p1);
|
||||
fnamebuf[p2-p1] = 0;
|
||||
for (i=0; i<include_stack_index; i++) {
|
||||
if ( !strcmp(fnamebuf,include_stack[i].fname )) {
|
||||
ast_log(LOG_ERROR,"File=%s, line=%d, column=%d: Nice Try!!! But %s has already been included (perhaps by another file), and would cause an infinite loop of file inclusions!!! Include directive ignored\n",
|
||||
my_file, my_lineno, my_col, fnamebuf);
|
||||
found=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !found ) {
|
||||
if (i == include_stack_index)
|
||||
error = 0; /* we can use this file */
|
||||
}
|
||||
if ( !error ) { /* valid file name */
|
||||
*p2 = 0;
|
||||
/* relative vs. absolute */
|
||||
if ( *(p1+1) != '/' ) {
|
||||
/* XXX must check overflows */
|
||||
strcpy(fnamebuf,ast_config_AST_CONFIG_DIR);
|
||||
strcat(fnamebuf,"/");
|
||||
strcat(fnamebuf,p1+1);
|
||||
|
@ -1526,8 +1528,6 @@ YY_RULE_SETUP
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
YY_BREAK
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
case YY_STATE_EOF(paren):
|
||||
|
|
Reference in New Issue