summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorSebastian Benoit <benno@cvs.openbsd.org>2019-01-29 21:34:38 +0000
committerSebastian Benoit <benno@cvs.openbsd.org>2019-01-29 21:34:38 +0000
commitd5a61b73a148f5c75d2ddaa2390354bbb7bf4f51 (patch)
tree66b0c22636c2fb307dfb09dee91f34d712b9ea2a /sbin
parent857abda60a6d6c12558c835b09151895f044ddc8 (diff)
replace err() with yyerror/YYERROR, only leave err() where we run out
of memory and can't do anything else. This way we don't terminate on config reload with a bad config. ok florian@
Diffstat (limited to 'sbin')
-rw-r--r--sbin/unwind/uw_parse.y36
1 files changed, 27 insertions, 9 deletions
diff --git a/sbin/unwind/uw_parse.y b/sbin/unwind/uw_parse.y
index bdda384e7e3..7bc40580581 100644
--- a/sbin/unwind/uw_parse.y
+++ b/sbin/unwind/uw_parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: uw_parse.y,v 1.5 2019/01/29 20:03:49 florian Exp $ */
+/* $OpenBSD: uw_parse.y,v 1.6 2019/01/29 21:34:37 benno Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -204,8 +204,12 @@ forwarderoptsl : STRING {
if(strlcpy(unwind_forwarder->name, $1,
sizeof(unwind_forwarder->name)) >=
- sizeof(unwind_forwarder->name))
- err(1, "%s too long", $1);
+ sizeof(unwind_forwarder->name)) {
+ free(unwind_forwarder);
+ yyerror("forwarder %s too long", $1);
+ free($1);
+ YYERROR;
+ }
SIMPLEQ_INSERT_TAIL(
&conf->unwind_forwarder_list,
@@ -216,6 +220,7 @@ forwarderoptsl : STRING {
if ($3 <= 0 || $3 > (int)USHRT_MAX) {
yyerror("invalid port: %lld", $3);
+ free($1);
YYERROR;
}
@@ -227,8 +232,12 @@ forwarderoptsl : STRING {
sizeof(unwind_forwarder->name), "%s@%d", $1,
(int)$3);
if (ret == -1 || (size_t)ret >=
- sizeof(unwind_forwarder->name))
- err(1, "%s too long", $1);
+ sizeof(unwind_forwarder->name)) {
+ free(unwind_forwarder);
+ yyerror("forwarder %s too long", $1);
+ free($1);
+ YYERROR;
+ }
SIMPLEQ_INSERT_TAIL(
&conf->unwind_forwarder_list,
@@ -241,8 +250,12 @@ forwarderoptsl : STRING {
if(strlcpy(unwind_forwarder->name, $1,
sizeof(unwind_forwarder->name)) >=
- sizeof(unwind_forwarder->name))
- err(1, "%s too long", $1);
+ sizeof(unwind_forwarder->name)) {
+ free(unwind_forwarder);
+ yyerror("forwarder %s too long", $1);
+ free($1);
+ YYERROR;
+ }
SIMPLEQ_INSERT_TAIL(
&conf->unwind_dot_forwarder_list,
@@ -253,6 +266,7 @@ forwarderoptsl : STRING {
if ($3 <= 0 || $3 > (int)USHRT_MAX) {
yyerror("invalid port: %lld", $3);
+ free($1);
YYERROR;
}
@@ -264,8 +278,12 @@ forwarderoptsl : STRING {
sizeof(unwind_forwarder->name), "%s@%d", $1,
(int)$3);
if (ret == -1 || (size_t)ret >=
- sizeof(unwind_forwarder->name))
- err(1, "%s too long", $1);
+ sizeof(unwind_forwarder->name)) {
+ free(unwind_forwarder);
+ yyerror("forwarder %s too long", $1);
+ free($1);
+ YYERROR;
+ }
SIMPLEQ_INSERT_TAIL(
&conf->unwind_dot_forwarder_list,