Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefine ECHO macro to not print unmatched text to the console #2010

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libyara/include/yara/hex_lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define yyget_extra hex_yyget_extra
#define yyget_lineno hex_yyget_lineno

// The default code for unmatched text is the ECHO macro, which write it to the console.
// It's not safe to print random bytes because it may cause the calling program to terminate.
#define ECHO

#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
Expand Down
9 changes: 8 additions & 1 deletion libyara/include/yara/lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define yyget_extra yara_yyget_extra
#define yyget_lineno yara_yyget_lineno

// The default code for unmatched text is the ECHO macro, which write it to the console.
// It's not safe to print random bytes because it may cause the calling program to terminate.
#define ECHO

#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
Expand All @@ -67,7 +70,11 @@ union YYSTYPE;
int yylex( \
union YYSTYPE* yylval_param, yyscan_t yyscanner, YR_COMPILER* compiler)


// The default behavior when a fatal error occurs in the parser is calling
// exit(YY_EXIT_FAILURE) for terminating the process. This is not acceptable
// for a library, which should return gracefully to the calling program. For
// this reason we redefine the YY_FATAL_ERROR macro so that it expands to our
// own function instead of the one provided by default.
#define YY_FATAL_ERROR(msg) yara_yyfatal(yyscanner, msg)


Expand Down
4 changes: 4 additions & 0 deletions libyara/include/yara/re_lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define yyget_extra re_yyget_extra
#define yyget_lineno re_yyget_lineno

// The default code for unmatched text is the ECHO macro, which write it to the console.
// It's not safe to print random bytes because it may cause the calling program to terminate.
#define ECHO

#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
typedef void* yyscan_t;
Expand Down
Loading