From 8a712df3c5b470c6966265f623ea4c994cccbc55 Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Mon, 27 Nov 2000 05:13:00 +0000 Subject: [PATCH] 2000-11-26 21:00 UTC+0800 Ron Pinkas * include/hberrors.h * source/pp/ppcomp.c * source/pp/ppcore.c + Added error support for Input buffer overflow . --- harbour/ChangeLog | 6 ++++++ harbour/include/hberrors.h | 1 + harbour/source/compiler/harbour.slx | 4 ++-- harbour/source/pp/ppcomp.c | 10 +++++++++- harbour/source/pp/ppcore.c | 3 ++- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 39e07ba9b9..9ad1572492 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +2000-11-26 21:00 UTC+0800 Ron Pinkas + * include/hberrors.h + * source/pp/ppcomp.c + * source/pp/ppcore.c + + Added error support for Input buffer overflow . + 2000-11-26 18:40 UTC+0800 Ron Pinkas * source/compiler/harbour.slx + Added Error message if NUMERALS_PER_LINE is exhausted, and set it to 3000 (just below apparent parser limitation) diff --git a/harbour/include/hberrors.h b/harbour/include/hberrors.h index aa585091b6..95b6fe0cd3 100644 --- a/harbour/include/hberrors.h +++ b/harbour/include/hberrors.h @@ -143,6 +143,7 @@ extern "C" { #define HB_PP_ERR_CANNOT_OPEN_RULES 15 #define HB_PP_ERR_BAD_RULES_FILE_NAME 16 #define HB_PP_ERR_TOO_MANY_INCLUDES 17 +#define HB_PP_ERR_BUFFER_OVERFLOW 18 #define HB_PP_WARN_DEFINE_REDEF 1 #define HB_PP_WARN_NO_DIRECTIVES 2 diff --git a/harbour/source/compiler/harbour.slx b/harbour/source/compiler/harbour.slx index f79c575631..76b3a4c435 100644 --- a/harbour/source/compiler/harbour.slx +++ b/harbour/source/compiler/harbour.slx @@ -509,7 +509,7 @@ int hb_comp_SLX_InterceptAction( int iRet, char *sToken ) else if( iRet == REJECT_OP ) { yylval.string = hb_compIdentifierNew( (char*) sToken, TRUE ); iRet = IDENTIFIER; } else - { printf( "Error SLX0001 Missing handler for %i\n", iRet ); hb_comp_iErrorCount++; } + { printf( "Error SLX0001 Missing handler for '%i' line: %i\n", iRet, hb_comp_iLine - 1 ); hb_comp_iErrorCount++; } } #ifdef SHOW_LEX_TOKENS @@ -641,7 +641,7 @@ static int hb_comp_SLX_ElementToken( char* szToken, unsigned int iTokenLen ) } else { - printf( "Error SLX0002 Too many numerals in line %i\n", hb_comp_iLine ); + printf( "Error SLX0002 Too many numerals in line: %i\n", hb_comp_iLine - 1 ); hb_comp_iErrorCount++; iTexts = 0; } diff --git a/harbour/source/pp/ppcomp.c b/harbour/source/pp/ppcomp.c index a87f0b5ca9..22b566a864 100644 --- a/harbour/source/pp/ppcomp.c +++ b/harbour/source/pp/ppcomp.c @@ -81,6 +81,11 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) lens += rdlen; hb_comp_iLine ++; + if( lens >= HB_PP_STR_SIZE ) + { + hb_compGenError( hb_pp_szErrors, 'F', HB_PP_ERR_BUFFER_OVERFLOW, NULL, NULL ); + } + if( s_szLine[ lens - 1 ] == ';' ) { lContinue = 1; @@ -209,7 +214,10 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) if( handl_o ) hb_pp_WrStr( handl_o, sOut ); -// printf( "%d : %s\n",hb_comp_iLine,sOut ); + #if 0 + printf( "%d : %s\n", hb_comp_iLine, sOut ); + #endif + return lens; } diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index 260f4826a0..5bfbeeece6 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -179,7 +179,8 @@ char * hb_pp_szErrors[] = "Value out of range in #pragma directive", "Can\'t open command definitions file: \'%s\'", "Invalid command definitions file name: \'%s\'", - "Too many nested #includes, can\'t open: \'%s\'" + "Too many nested #includes, can\'t open: \'%s\'", + "Input buffer overflow" }; /* Table with warnings */