From: tb Date: Sat, 10 Aug 2024 05:47:29 +0000 (+0000) Subject: relayd: improve config validation with -n X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2b4fa706c59b1ffeea7aee5728314a5d09225ed6;p=openbsd 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 --- 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 @@ -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 @@ -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; };