1
0
Fork 0

Bug fix/fix bison error message leak (#5864)

* define YYSTACK_USE_ALLOCA for Bison

    we are now using alloca here explicitly because we may
    otherwise leak error messages that are generated by Bison.
    Bison reports all its errors via the function `Aqlerror`, which
    will receive the error message as a constant string. So we
    must not free the string inside `Aqlerror`, and we cannot even
    tell if the error message is a dynamically allocated error
    message or a hard-coded error message that resides in some
    static part of the program.
    Even worse, `Aqlerror` does not return control to Bison but throws
    an exception... So the best thing we can do here is to not use
    dynamically memory allocation by Bison, but make it use alloca.

* added generated files
This commit is contained in:
Jan 2018-07-13 14:06:52 +02:00 committed by Michael Hackstein
parent 1240090cd8
commit 8a659cd16f
6 changed files with 981 additions and 787 deletions

File diff suppressed because it is too large Load Diff

View File

@ -126,7 +126,7 @@ extern int Aqldebug;
union YYSTYPE
{
#line 19 "Aql/grammar.y" /* yacc.c:1909 */
#line 32 "Aql/grammar.y" /* yacc.c:1909 */
arangodb::aql::AstNode* node;
struct {

View File

@ -126,7 +126,7 @@ extern int Aqldebug;
union YYSTYPE
{
#line 19 "Aql/grammar.y" /* yacc.c:1909 */
#line 32 "Aql/grammar.y" /* yacc.c:1909 */
arangodb::aql::AstNode* node;
struct {

View File

@ -7,6 +7,19 @@
%error-verbose
%{
// we are using alloca here explicitly because we may
// otherwise leak error messages that are generated by Bison.
// Bison reports all its errors via the function `Aqlerror`, which
// will receive the error message as a constant string. So we
// must not free the string inside `Aqlerror`, and we cannot even
// tell if the error message is a dynamically allocated error
// message or a hard-coded error message that resides in some
// static part of the program.
// Even worse, `Aqlerror` does not return control to Bison but throws
// an exception... So the best thing we can do here is to not use
// dynamically memory allocation by Bison, but make it use alloca.
#define YYSTACK_USE_ALLOCA 1
#include "Aql/Aggregator.h"
#include "Aql/AstNode.h"
#include "Aql/Function.h"

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@
#include "Basics/Common.h"
#include "Basics/conversions.h"
#include "Basics/NumberUtils.h"
#include "Basics/StringUtils.h"
// introduce the namespace here, otherwise following references to
// the namespace in auto-generated headers might fail
@ -33,11 +32,12 @@ class Parser;
}
}
#include "Aql/AstNode.h"
#include "Aql/grammar.h"
#include "Aql/Parser.h"
#include <algorithm>
#define YY_EXTRA_TYPE arangodb::aql::Parser*
#define YY_USER_ACTION \
@ -50,10 +50,7 @@ class Parser;
#define YY_NO_INPUT 1
#define YY_INPUT(resultBuffer, resultState, maxBytesToRead) { \
size_t length = yyextra->remainingLength(); \
if (length > static_cast<size_t>(maxBytesToRead)) { \
length = static_cast<size_t>(maxBytesToRead); \
} \
size_t length = std::min(yyextra->remainingLength(), static_cast<size_t>(maxBytesToRead)); \
if (length > 0) { \
yyextra->fillBuffer(resultBuffer, length); \
resultState = length; \