From 1fae650d42b90b23b2b890ad5f51b5d381b74127 Mon Sep 17 00:00:00 2001 From: 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: http://svn.digium.com/svn/asterisk/trunk@22957 f38db490-d61c-443f-a65b-d21fe96a405b --- pbx/ael/ael.flex | 98 +++++++++++++++++++++++------------------------ pbx/ael/ael_lex.c | 98 +++++++++++++++++++++++------------------------ 2 files changed, 98 insertions(+), 98 deletions(-) diff --git a/pbx/ael/ael.flex b/pbx/ael/ael.flex index 77bfcb677..c5a4cfd6e 100644 --- a/pbx/ael/ael.flex +++ b/pbx/ael/ael.flex @@ -318,61 +318,61 @@ 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); + int i; + 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); + int i; + strncpy(fnamebuf, p1, p2-p1); + fnamebuf[p2-p1] = 0; + for (i=0; i