From 401cb2bb170f94934b3c06f182ef8826b4f56326 Mon Sep 17 00:00:00 2001 From: Aaron Jones Date: Sun, 15 May 2016 00:00:23 +0000 Subject: [PATCH] ircd_lexer: fix crash with very large config option strings --- ircd/ircd_lexer.l | 4 ++-- ircd/s_conf.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ircd/ircd_lexer.l b/ircd/ircd_lexer.l index 3d7503d9..99ce22cd 100644 --- a/ircd/ircd_lexer.l +++ b/ircd/ircd_lexer.l @@ -58,7 +58,7 @@ char *current_file = conffilebuf; FILE *inc_fbfile_in[MAX_INCLUDE_DEPTH]; -char linebuf[512]; +char yy_linebuf[16384]; #undef YY_INPUT @@ -79,7 +79,7 @@ include \.include{ws}(\<.*\>|\".*\") %% {include} { cinclude(); } "/*" { ccomment(); } -\n.* { strcpy(linebuf, yytext+1); lineno++; yyless(1); } +\n.* { rb_strlcpy(yy_linebuf, yytext+1, sizeof(yy_linebuf)); lineno++; yyless(1); } {ws} ; {comment} { hashcomment(); } diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 2a7d5b97..74df1cfa 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -56,7 +56,7 @@ struct config_server_hide ConfigServerHide; extern int yyparse(void); /* defined in y.tab.c */ -extern char linebuf[]; +extern char yy_linebuf[16384]; /* defined in ircd_lexer.l */ static rb_bh *confitem_heap = NULL; @@ -1639,7 +1639,7 @@ yyerror(const char *msg) { char newlinebuf[BUFSIZE]; - strip_tabs(newlinebuf, linebuf, strlen(linebuf)); + strip_tabs(newlinebuf, yy_linebuf, strlen(yy_linebuf)); ierror("\"%s\", line %d: %s at '%s'", conffilebuf, lineno + 1, msg, newlinebuf); sendto_realops_snomask(SNO_GENERAL, L_ALL, "\"%s\", line %d: %s at '%s'",