Fix setvar parsing of quoted data

This commit is contained in:
Victor Hora 2018-04-30 19:45:11 -04:00 committed by Felipe Zimmerle
parent e47125c55e
commit 5e40850697
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
4 changed files with 927 additions and 977 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
// A Bison parser, made by GNU Bison 3.0.4. // A Bison parser, made by GNU Bison 3.0.2.
// Skeleton interface for Bison LALR(1) parsers in C++ // Skeleton interface for Bison LALR(1) parsers in C++
// Copyright (C) 2002-2015 Free Software Foundation, Inc. // Copyright (C) 2002-2013 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
@ -40,7 +40,7 @@
#ifndef YY_YY_SECLANG_PARSER_HH_INCLUDED #ifndef YY_YY_SECLANG_PARSER_HH_INCLUDED
# define YY_YY_SECLANG_PARSER_HH_INCLUDED # define YY_YY_SECLANG_PARSER_HH_INCLUDED
// // "%code requires" blocks. // // "%code requires" blocks.
#line 10 "seclang-parser.yy" // lalr1.cc:377 #line 10 "seclang-parser.yy" // lalr1.cc:372
#include <string> #include <string>
#include <iterator> #include <iterator>
@ -379,14 +379,13 @@ using modsecurity::operators::Operator;
#line 383 "seclang-parser.hh" // lalr1.cc:377 #line 383 "seclang-parser.hh" // lalr1.cc:372
# include <cassert> # include <cassert>
# include <cstdlib> // std::abort # include <vector>
# include <iostream> # include <iostream>
# include <stdexcept> # include <stdexcept>
# include <string> # include <string>
# include <vector>
# include "stack.hh" # include "stack.hh"
# include "location.hh" # include "location.hh"
#include <typeinfo> #include <typeinfo>
@ -456,7 +455,7 @@ using modsecurity::operators::Operator;
namespace yy { namespace yy {
#line 460 "seclang-parser.hh" // lalr1.cc:377 #line 459 "seclang-parser.hh" // lalr1.cc:372
@ -473,13 +472,13 @@ namespace yy {
/// Empty construction. /// Empty construction.
variant () variant ()
: yytypeid_ (YY_NULLPTR) : yytname_ (YY_NULLPTR)
{} {}
/// Construct and fill. /// Construct and fill.
template <typename T> template <typename T>
variant (const T& t) variant (const T& t)
: yytypeid_ (&typeid (T)) : yytname_ (typeid (T).name ())
{ {
YYASSERT (sizeof (T) <= S); YYASSERT (sizeof (T) <= S);
new (yyas_<T> ()) T (t); new (yyas_<T> ()) T (t);
@ -488,7 +487,7 @@ namespace yy {
/// Destruction, allowed only if empty. /// Destruction, allowed only if empty.
~variant () ~variant ()
{ {
YYASSERT (!yytypeid_); YYASSERT (!yytname_);
} }
/// Instantiate an empty \a T in here. /// Instantiate an empty \a T in here.
@ -496,9 +495,9 @@ namespace yy {
T& T&
build () build ()
{ {
YYASSERT (!yytypeid_); YYASSERT (!yytname_);
YYASSERT (sizeof (T) <= S); YYASSERT (sizeof (T) <= S);
yytypeid_ = & typeid (T); yytname_ = typeid (T).name ();
return *new (yyas_<T> ()) T; return *new (yyas_<T> ()) T;
} }
@ -507,9 +506,9 @@ namespace yy {
T& T&
build (const T& t) build (const T& t)
{ {
YYASSERT (!yytypeid_); YYASSERT (!yytname_);
YYASSERT (sizeof (T) <= S); YYASSERT (sizeof (T) <= S);
yytypeid_ = & typeid (T); yytname_ = typeid (T).name ();
return *new (yyas_<T> ()) T (std::move((T&)t)); return *new (yyas_<T> ()) T (std::move((T&)t));
} }
@ -518,7 +517,7 @@ namespace yy {
T& T&
as () as ()
{ {
YYASSERT (*yytypeid_ == typeid (T)); YYASSERT (yytname_ == typeid (T).name ());
YYASSERT (sizeof (T) <= S); YYASSERT (sizeof (T) <= S);
return *yyas_<T> (); return *yyas_<T> ();
} }
@ -528,7 +527,7 @@ namespace yy {
const T& const T&
as () const as () const
{ {
YYASSERT (*yytypeid_ == typeid (T)); YYASSERT (yytname_ == typeid (T).name ());
YYASSERT (sizeof (T) <= S); YYASSERT (sizeof (T) <= S);
return *yyas_<T> (); return *yyas_<T> ();
} }
@ -545,8 +544,8 @@ namespace yy {
void void
swap (self_type& other) swap (self_type& other)
{ {
YYASSERT (yytypeid_); YYASSERT (yytname_);
YYASSERT (*yytypeid_ == *other.yytypeid_); YYASSERT (yytname_ == other.yytname_);
std::swap (as<T> (), other.as<T> ()); std::swap (as<T> (), other.as<T> ());
} }
@ -576,7 +575,7 @@ namespace yy {
destroy () destroy ()
{ {
as<T> ().~T (); as<T> ().~T ();
yytypeid_ = YY_NULLPTR; yytname_ = YY_NULLPTR;
} }
private: private:
@ -611,7 +610,7 @@ namespace yy {
} yybuffer_; } yybuffer_;
/// Whether the content is built: if defined, the name of the stored type. /// Whether the content is built: if defined, the name of the stored type.
const std::type_info *yytypeid_; const char *yytname_;
}; };
@ -1204,12 +1203,9 @@ namespace yy {
/// (External) token type, as returned by yylex. /// (External) token type, as returned by yylex.
typedef token::yytokentype token_type; typedef token::yytokentype token_type;
/// Symbol type: an internal symbol number. /// Internal symbol number.
typedef int symbol_number_type; typedef int symbol_number_type;
/// The symbol type number to denote an empty symbol.
enum { empty_symbol = -2 };
/// Internal symbol number for tokens (subsumed by symbol_number_type). /// Internal symbol number for tokens (subsumed by symbol_number_type).
typedef unsigned short int token_number_type; typedef unsigned short int token_number_type;
@ -1255,15 +1251,8 @@ namespace yy {
const semantic_type& v, const semantic_type& v,
const location_type& l); const location_type& l);
/// Destroy the symbol.
~basic_symbol (); ~basic_symbol ();
/// Destroy contents, and record that is empty.
void clear ();
/// Whether empty.
bool empty () const;
/// Destructive move, \a s is emptied into this. /// Destructive move, \a s is emptied into this.
void move (basic_symbol& s); void move (basic_symbol& s);
@ -1293,23 +1282,21 @@ namespace yy {
/// Constructor from (external) token numbers. /// Constructor from (external) token numbers.
by_type (kind_type t); by_type (kind_type t);
/// Record that this symbol is empty.
void clear ();
/// Steal the symbol type from \a that. /// Steal the symbol type from \a that.
void move (by_type& that); void move (by_type& that);
/// The (internal) type number (corresponding to \a type). /// The (internal) type number (corresponding to \a type).
/// \a empty when empty. /// -1 when this symbol is empty.
symbol_number_type type_get () const; symbol_number_type type_get () const;
/// The token. /// The token.
token_type token () const; token_type token () const;
enum { empty = 0 };
/// The symbol type. /// The symbol type.
/// \a empty_symbol when empty. /// -1 when this symbol is empty.
/// An int, not token_number_type, to be able to store empty_symbol. token_number_type type;
int type;
}; };
/// "External" symbols: returned by the scanner. /// "External" symbols: returned by the scanner.
@ -2701,9 +2688,9 @@ namespace yy {
/// Generate an error message. /// Generate an error message.
/// \param yystate the state where the error occurred. /// \param yystate the state where the error occurred.
/// \param yyla the lookahead token. /// \param yytoken the lookahead token type, or yyempty_.
virtual std::string yysyntax_error_ (state_type yystate, virtual std::string yysyntax_error_ (state_type yystate,
const symbol_type& yyla) const; symbol_number_type yytoken) const;
/// Compute post-reduction state. /// Compute post-reduction state.
/// \param yystate the current state /// \param yystate the current state
@ -2806,21 +2793,16 @@ namespace yy {
/// Copy constructor. /// Copy constructor.
by_state (const by_state& other); by_state (const by_state& other);
/// Record that this symbol is empty.
void clear ();
/// Steal the symbol type from \a that. /// Steal the symbol type from \a that.
void move (by_state& that); void move (by_state& that);
/// The (internal) type number (corresponding to \a state). /// The (internal) type number (corresponding to \a state).
/// \a empty_symbol when empty. /// "empty" when empty.
symbol_number_type type_get () const; symbol_number_type type_get () const;
/// The state number used to denote an empty symbol. enum { empty = 0 };
enum { empty_state = -1 };
/// The state. /// The state.
/// \a empty when empty.
state_type state; state_type state;
}; };
@ -2861,12 +2843,13 @@ namespace yy {
/// Pop \a n symbols the three stacks. /// Pop \a n symbols the three stacks.
void yypop_ (unsigned int n = 1); void yypop_ (unsigned int n = 1);
/// Constants. // Constants.
enum enum
{ {
yyeof_ = 0, yyeof_ = 0,
yylast_ = 3310, ///< Last index in yytable_. yylast_ = 3310, ///< Last index in yytable_.
yynnts_ = 15, ///< Number of nonterminal symbols. yynnts_ = 15, ///< Number of nonterminal symbols.
yyempty_ = -2,
yyfinal_ = 334, ///< Termination state number. yyfinal_ = 334, ///< Termination state number.
yyterror_ = 1, yyterror_ = 1,
yyerrcode_ = 256, yyerrcode_ = 256,
@ -3516,19 +3499,9 @@ namespace yy {
template <typename Base> template <typename Base>
inline inline
seclang_parser::basic_symbol<Base>::~basic_symbol () seclang_parser::basic_symbol<Base>::~basic_symbol ()
{
clear ();
}
template <typename Base>
inline
void
seclang_parser::basic_symbol<Base>::clear ()
{ {
// User destructor. // User destructor.
symbol_number_type yytype = this->type_get (); symbol_number_type yytype = this->type_get ();
basic_symbol<Base>& yysym = *this;
(void) yysym;
switch (yytype) switch (yytype)
{ {
default: default:
@ -3767,15 +3740,6 @@ namespace yy {
break; break;
} }
Base::clear ();
}
template <typename Base>
inline
bool
seclang_parser::basic_symbol<Base>::empty () const
{
return Base::type_get () == empty_symbol;
} }
template <typename Base> template <typename Base>
@ -4021,7 +3985,7 @@ namespace yy {
// by_type. // by_type.
inline inline
seclang_parser::by_type::by_type () seclang_parser::by_type::by_type ()
: type (empty_symbol) : type (empty)
{} {}
inline inline
@ -4034,19 +3998,12 @@ namespace yy {
: type (yytranslate_ (t)) : type (yytranslate_ (t))
{} {}
inline
void
seclang_parser::by_type::clear ()
{
type = empty_symbol;
}
inline inline
void void
seclang_parser::by_type::move (by_type& that) seclang_parser::by_type::move (by_type& that)
{ {
type = that.type; type = that.type;
that.clear (); that.type = empty;
} }
inline inline
@ -6123,7 +6080,7 @@ namespace yy {
} // yy } // yy
#line 6127 "seclang-parser.hh" // lalr1.cc:377 #line 6084 "seclang-parser.hh" // lalr1.cc:372

View File

@ -471,8 +471,8 @@ static const flex_int16_t yy_accept[3946] =
510, 502, 526, 283, 284, 526, 493, 493, 492, 495, 510, 502, 526, 283, 284, 526, 493, 493, 492, 495,
493, 491, 491, 490, 495, 491, 150, 520, 521, 522, 493, 491, 491, 490, 495, 491, 150, 520, 521, 522,
137, 136, 137, 137, 137, 137, 137, 137, 141, 140, 137, 136, 137, 137, 137, 137, 137, 137, 141, 140,
145, 146, 146, 145, 143, 142, 140, 147, 149, 149, 145, 146, 146, 145, 143, 142, 140, 148, 149, 149,
147, 147, 513, 264, 0, 267, 267, 267, 0, 0, 147, 148, 513, 264, 0, 267, 267, 267, 0, 0,
0, 0, 0, 0, 0, 0, 216, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216, 0, 0, 0,
0, 0, 514, 0, 0, 0, 0, 0, 0, 0, 0, 0, 514, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 410, 0, 0, 0, 0, 0, 0, 0, 0, 0, 410, 0, 0, 0,
@ -501,8 +501,8 @@ static const flex_int16_t yy_accept[3946] =
493, 0, 494, 493, 491, 0, 0, 491, 0, 491, 493, 0, 494, 493, 491, 0, 0, 491, 0, 491,
520, 521, 522, 0, 0, 0, 0, 0, 0, 138, 520, 521, 522, 0, 0, 0, 0, 0, 0, 138,
139, 145, 0, 0, 145, 0, 145, 144, 147, 0, 139, 145, 0, 0, 145, 0, 145, 144, 148, 0,
0, 147, 0, 147, 267, 0, 0, 0, 0, 0, 0, 148, 0, 148, 267, 0, 0, 0, 0, 0,
0, 0, 215, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 0, 0, 0, 0,
514, 515, 0, 0, 0, 393, 0, 0, 383, 0, 514, 515, 0, 0, 0, 393, 0, 0, 383, 0,
0, 0, 418, 0, 0, 0, 0, 0, 0, 0, 0, 0, 418, 0, 0, 0, 0, 0, 0, 0,
@ -526,7 +526,7 @@ static const flex_int16_t yy_accept[3946] =
0, 0, 0, 0, 108, 109, 508, 511, 503, 0, 0, 0, 0, 0, 108, 109, 508, 511, 503, 0,
0, 508, 505, 509, 0, 285, 0, 0, 493, 0, 0, 508, 505, 509, 0, 285, 0, 0, 493, 0,
0, 0, 491, 0, 0, 0, 0, 0, 0, 0, 0, 0, 491, 0, 0, 0, 0, 0, 0, 0,
145, 0, 0, 0, 147, 0, 0, 267, 0, 0, 145, 0, 0, 0, 148, 0, 0, 267, 0, 0,
0, 0, 0, 169, 0, 0, 0, 0, 0, 0, 0, 0, 0, 169, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 222, 515, 359, 0, 0, 394, 0, 0, 0, 0, 222, 515, 359, 0, 0, 394,
@ -551,7 +551,7 @@ static const flex_int16_t yy_accept[3946] =
0, 0, 0, 0, 0, 0, 65, 0, 0, 109, 0, 0, 0, 0, 0, 0, 65, 0, 0, 109,
508, 507, 0, 504, 0, 505, 509, 285, 0, 286, 508, 507, 0, 504, 0, 505, 509, 285, 0, 286,
493, 0, 491, 0, 0, 0, 0, 0, 145, 0, 493, 0, 491, 0, 0, 0, 0, 0, 145, 0,
147, 0, 267, 267, 212, 0, 0, 214, 0, 0, 148, 0, 267, 267, 212, 0, 0, 214, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -6698,15 +6698,15 @@ YY_RULE_SETUP
case 147: case 147:
/* rule 147 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 722 "seclang-scanner.ll" #line 722 "seclang-scanner.ll"
{ return p::make_FREE_TEXT_QUOTE_MACRO_EXPANSION(yytext, *driver.loc.back()); } { BEGIN(EXPECTING_ACTIONS_ENDS_WITH_DOUBLE_QUOTE); }
YY_BREAK YY_BREAK
case 148: case 148:
/* rule 148 can match eol */
YY_RULE_SETUP YY_RULE_SETUP
#line 723 "seclang-scanner.ll" #line 723 "seclang-scanner.ll"
{ BEGIN(EXPECTING_ACTIONS_ENDS_WITH_DOUBLE_QUOTE); } { return p::make_FREE_TEXT_QUOTE_MACRO_EXPANSION(yytext, *driver.loc.back()); }
YY_BREAK YY_BREAK
case 149: case 149:
/* rule 149 can match eol */ /* rule 149 can match eol */

View File

@ -718,8 +718,8 @@ EQUALS_MINUS (?i:=\-)
<SETVAR_ACTION_QUOTED_WAITING_CONTENT>{ <SETVAR_ACTION_QUOTED_WAITING_CONTENT>{
{FREE_TEXT_EQUALS_MACRO_EXPANSION} { return p::make_FREE_TEXT_QUOTE_MACRO_EXPANSION(yytext, *driver.loc.back()); }
\' { BEGIN(EXPECTING_ACTIONS_ENDS_WITH_DOUBLE_QUOTE); } \' { BEGIN(EXPECTING_ACTIONS_ENDS_WITH_DOUBLE_QUOTE); }
{FREE_TEXT_EQUALS_MACRO_EXPANSION} { return p::make_FREE_TEXT_QUOTE_MACRO_EXPANSION(yytext, *driver.loc.back()); }
.|\n { BEGIN(EXPECTING_ACTIONS_ENDS_WITH_DOUBLE_QUOTE); yyless(0); } .|\n { BEGIN(EXPECTING_ACTIONS_ENDS_WITH_DOUBLE_QUOTE); yyless(0); }
} }