git: 768149ff156e - main - jail: make sure jail.conf parse errors exit, and not crash. Reported by: Mason Loring Bliss

From: Jamie Gritton <jamie_at_FreeBSD.org>
Date: Sun, 21 Jan 2024 05:22:15 UTC
The branch main has been updated by jamie:

URL: https://cgit.FreeBSD.org/src/commit/?id=768149ff156e7d34a035853030bf946ca94cb461

commit 768149ff156e7d34a035853030bf946ca94cb461
Author:     Jamie Gritton <jamie@FreeBSD.org>
AuthorDate: 2024-01-21 05:20:59 +0000
Commit:     Jamie Gritton <jamie@FreeBSD.org>
CommitDate: 2024-01-21 05:20:59 +0000

    jail: make sure jail.conf parse errors exit, and not crash.
    Reported by:    Mason Loring Bliss
---
 usr.sbin/jail/jailparse.y | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/jail/jailparse.y b/usr.sbin/jail/jailparse.y
index 047ca882e59f..048cfcf11c2b 100644
--- a/usr.sbin/jail/jailparse.y
+++ b/usr.sbin/jail/jailparse.y
@@ -234,16 +234,19 @@ extern int YYLEX_DECL();
 static void
 YYERROR_DECL()
 {
+	struct cflex *cflex = yyget_extra(scanner);
+
 	if (!yyget_text(scanner))
 		warnx("%s line %d: %s",
-		    yyget_extra(scanner)->cfname, yyget_lineno(scanner), s);
+		    cflex->cfname, yyget_lineno(scanner), s);
 	else if (!yyget_text(scanner)[0])
 		warnx("%s: unexpected EOF",
-		    yyget_extra(scanner)->cfname);
+		    cflex->cfname);
 	else
 		warnx("%s line %d: %s: %s",
-		    yyget_extra(scanner)->cfname, yyget_lineno(scanner),
+		    cflex->cfname, yyget_lineno(scanner),
 		    yyget_text(scanner), s);
+	cflex->error = 1;
 }
 
 /* Handle special parameters (i.e. the include directive).