1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

0024897: Possibility of uncontrolled exit if scanner fails in ExprIntrp

Macro YY_FATAL_ERROR() is defined in ExprIntrp.lex in order to have exception instead of program exit in case of scanner error. Fixed-length string buffers are replaced by TCollection_AsciiString to avoid buffer overflow.
Some code refactoring: declarations of functions moved to header file, unused global declarations and variables removed, compiler warnings fixed or disabled, obsolete EDL file removed.
Test case for issue CR24897
Correction of MSVC compiler warning when scanner is generated using Flex 2.5.35 on Linux
This commit is contained in:
abv
2014-05-29 15:05:47 +04:00
committed by apn
parent cae42e78e5
commit 2a54ebbf29
10 changed files with 87 additions and 112 deletions

View File

@@ -19,18 +19,16 @@
%{
#include <ExprIntrp.tab.h>
#include <ExprIntrp_yaccintrf.hxx>
#define YY_SKIP_YYWRAP
static YY_BUFFER_STATE ExprIntrp_bufstring;
void ExprIntrp_SetResult();
void ExprIntrp_SetDegree();
int ExprIntrlex (void);
void ExprIntrp_start_string(char* str)
void ExprIntrp_start_string(const char* str)
{
ExprIntrp_bufstring = ExprIntrp_scan_string(str);
// depending on configuration and generator, yyconst may be defined as const or empty
ExprIntrp_bufstring = ExprIntrp_scan_string((yyconst char*)str);
}
void ExprIntrp_stop_string()
@@ -39,11 +37,14 @@ void ExprIntrp_stop_string()
ExprIntrp_bufstring = (YY_BUFFER_STATE) 0;
}
int yywrap()
static int yywrap()
{
return 1;
}
// provide safe error handler (exception instead of exit())
#define YY_FATAL_ERROR(msg) ExprIntrperror(msg)
#ifdef _MSC_VER
// add includes for flex 2.91 (Linux version)
#include <stdlib.h>
@@ -52,8 +53,14 @@ int yywrap()
// Avoid includion of unistd.h if parser is generated on Linux (flex 2.5.35)
#define YY_NO_UNISTD_H
// disable MSVC warnings in flex 2.89 code
#pragma warning(disable:4131 4244 4273 4127)
// disable MSVC warnings in flex 2.89 and 2.5.35 code
// Note that Intel compiler also defines _MSC_VER but has different warning ids
#if defined(__INTEL_COMPILER)
#pragma warning(disable:177 1786 1736)
#else
#pragma warning(disable:4131 4244 4273 4127 4267)
#endif
#endif
#ifdef __GNUC__