diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-08-10 05:47:30 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-08-10 05:47:30 +0000 |
commit | 3a968935fc9a517e6baa879a560be1df4953eb5f (patch) | |
tree | bc6a05cf87d26124850aa6defd747cb6587e8d99 /usr.sbin/relayd | |
parent | aa175c23d8171d8fc6dc32ecb5fa249ca0db7bf3 (diff) |
relayd: improve config validation with -n
pf's rule names are limited by 32 characters, so lower the length bounds
for redirect names and tags that relayd accepts as valid config but would
later fail to load into pf. Also display the offending name on error.
from Mark Johnston
ok florian
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r-- | usr.sbin/relayd/parse.y | 7 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 8 |
2 files changed, 7 insertions, 8 deletions
diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y index 739ff164e2e..eea485c4471 100644 --- a/usr.sbin/relayd/parse.y +++ b/usr.sbin/relayd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.256 2024/06/17 08:02:57 sashan Exp $ */ +/* $OpenBSD: parse.y,v 1.257 2024/08/10 05:47:29 tb Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -490,7 +490,7 @@ rdr : REDIRECT STRING { if (strlcpy(srv->conf.name, $2, sizeof(srv->conf.name)) >= sizeof(srv->conf.name)) { - yyerror("redirection name truncated"); + yyerror("redirection name truncated: %s", $2); free($2); free(srv); YYERROR; @@ -628,7 +628,8 @@ rdroptsl : forwardmode TO tablespec interface { if (strlcpy(rdr->conf.tag, $3, sizeof(rdr->conf.tag)) >= sizeof(rdr->conf.tag)) { - yyerror("redirection tag name truncated"); + yyerror("redirection tag name truncated: %s", + $3); free($3); YYERROR; } diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 2f55c2bb23b..ce8cabd68d2 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.273 2024/06/17 08:02:57 sashan Exp $ */ +/* $OpenBSD: relayd.h,v 1.274 2024/08/10 05:47:29 tb Exp $ */ /* * Copyright (c) 2006 - 2016 Reyk Floeter <reyk@openbsd.org> @@ -57,9 +57,7 @@ #define LABEL_NAME_SIZE 1024 #define TAG_NAME_SIZE 64 #define TABLE_NAME_SIZE 64 -#define RD_TAG_NAME_SIZE 64 #define RT_LABEL_SIZE 32 -#define SRV_NAME_SIZE 64 #define MAX_NAME_SIZE 64 #define SRV_MAX_VIRTS 16 #define TLS_NAME_SIZE 512 @@ -545,8 +543,8 @@ struct rdr_config { objid_t backup_id; int mode; union hashkey key; - char name[SRV_NAME_SIZE]; - char tag[RD_TAG_NAME_SIZE]; + char name[PF_TABLE_NAME_SIZE]; + char tag[PF_TAG_NAME_SIZE]; struct timeval timeout; }; |