Skip to contentSkip to conversation

conntrackd: Use strdup in lexer

PATCH Superseded Ash Hughes 2 participants 2 messages May 27, 2019 – May 30, 2019 netfilter

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ash Hughes

author
#0 lore raw

PATCH 1/1 conntrackd: Use strdup in lexer

Use strdup in the config file lexer to copy strings to yylval.string. This should solve the "[ERROR] unknown layer 3 protocol" problem here: https://www.spinics.net/lists/netfilter/msg58628.html

---
 src/read_config_lex.l |  8 +++---
 src/read_config_yy.y  | 57 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 4 deletions(-)
src/read_config_lex.l +4 -4
index 120bc00..b0d9e61 100644
@@ -142,9 +142,9 @@ notrack		[N|n][O|o][T|t][R|r][A|a][C|c][K|k]
 {is_off}		{ return T_OFF; }
 {integer}		{ yylval.val = atoi(yytext); return T_NUMBER; }
 {signed_integer}	{ yylval.val = atoi(yytext); return T_SIGNED_NUMBER; }
-{ip4}			{ yylval.string = yytext; return T_IP; }
-{ip6}			{ yylval.string = yytext; return T_IP; }
-{path}			{ yylval.string = yytext; return T_PATH_VAL; }
+{ip4}			{ yylval.string = strdup(yytext); return T_IP; }
+{ip6}			{ yylval.string = strdup(yytext); return T_IP; }
+{path}			{ yylval.string = strdup(yytext); return T_PATH_VAL; }
 {alarm}			{ return T_ALARM; }
 {persistent}		{ dlog(LOG_WARNING, "Now `persistent' mode "
 			       "is called `alarm'. Please, update "
@@ -156,7 +156,7 @@ notrack		[N|n][O|o][T|t][R|r][A|a][C|c][K|k]
 			       "your conntrackd.conf file.\n");
 			  return T_FTFW; }
 {notrack}		{ return T_NOTRACK; }
-{string}		{ yylval.string = yytext; return T_STRING; }
+{string}		{ yylval.string = strdup(yytext); return T_STRING; }
 
 {comment}	;
 {ws}		;
src/read_config_yy.y +57 -0

337 lines not on this page · raw message

Signature · 1 line
2.21.0
#1 lore raw

Hi Ash,

Quoted 4 lines · Ash Hughes

Use strdup in the config file lexer to copy strings to yylval.string. This should solve the "[ERROR] unknown layer 3 protocol" problem here:
https://www.spinics.net/lists/netfilter/msg58628.html

Thanks, this indeed fixes the problem.

One request below:

src/read_config_yy.y logfile_bool : T_LOG T_OFF · line 120

Quoted 9 lines
src/read_config_yy.y +1 -0
index 1d510ed..1cb9cce 100644
@@ -117,6 +117,7 @@ logfile_bool : T_LOG T_OFF
 logfile_path : T_LOG T_PATH_VAL
 {
 	strncpy(conf.logfile, $2, FILENAME_MAXLEN);
+    free($2);

^^^^

Could you submit a v2 using 8-char tab indentation instead of spaces?

Thanks!