From 9033ecfaa22c4048460d6ac0edb19ab9d1abe98a Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Thu, 27 Apr 2006 19:29:14 +0000 Subject: [PATCH] slightly restructure a block to reduce nesting, mark some missing error checks git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@22957 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- pbx/ael/ael.flex | 102 +++++++++++++++++++++++----------------------- pbx/ael/ael_lex.c | 102 +++++++++++++++++++++++----------------------- 2 files changed, 102 insertions(+), 102 deletions(-) diff --git a/pbx/ael/ael.flex b/pbx/ael/ael.flex index 77bfcb677b..c5a4cfd6e6 100644 --- a/pbx/ael/ael.flex +++ b/pbx/ael/ael.flex @@ -318,62 +318,62 @@ includes { STORE_POS; return KW_INCLUDES;} \#include[ \t]+\"[^\"]+\" { FILE *in1; char fnamebuf[1024],*p1,*p2; + int error = 1; /* don't use the file if set */ + p1 = strchr(yytext,'"'); + p2 = strrchr(yytext,'"'); 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 { - p1 = strchr(yytext,'"'); - p2 = strrchr(yytext,'"'); - if ( (int)(p2-p1) > 1023 ) { - 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= 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 { - p1 = strchr(yytext,'"'); - p2 = strrchr(yytext,'"'); - if ( (int)(p2-p1) > 1023 ) { - 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