From a43c3f9026f27033758dccd3e48b089490114475 Mon Sep 17 00:00:00 2001
From: Daniel Hartmeier <dhartmei@cvs.openbsd.org>
Date: Thu, 9 Sep 2004 22:08:43 +0000
Subject: Copy out anchors with relative paths and wildcards correctly, from
 jaredy@, ok henning@, mcbride@, deraadt@

---
 sys/net/pf_ioctl.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'sys/net/pf_ioctl.c')

diff --git a/sys/net/pf_ioctl.c b/sys/net/pf_ioctl.c
index 0278de8c19c..2eb48a748f2 100644
--- a/sys/net/pf_ioctl.c
+++ b/sys/net/pf_ioctl.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: pf_ioctl.c,v 1.129 2004/07/22 23:21:10 msf Exp $ */
+/*	$OpenBSD: pf_ioctl.c,v 1.130 2004/09/09 22:08:42 dhartmei Exp $ */
 
 /*
  * Copyright (c) 2001 Daniel Hartmeier
@@ -512,11 +512,13 @@ pf_anchor_copyout(const struct pf_ruleset *rs, const struct pf_rule *r,
 			printf("pf_anchor_copyout: '%s' '%s'\n", a, b);
 			return (1);
 		}
-		strlcat(pr->anchor_call, b + (a[0] ? strlen(a) + 1 : 0),
-		    sizeof(pr->anchor_call));
+		if (strlen(b) > strlen(a))
+			strlcat(pr->anchor_call, b + (a[0] ? strlen(a) + 1 : 0),
+			    sizeof(pr->anchor_call));
 	}
 	if (r->anchor_wildcard)
-		strlcat(pr->anchor_call, "/*", sizeof(pr->anchor_call));
+		strlcat(pr->anchor_call, pr->anchor_call[0] ? "/*" : "*",
+		    sizeof(pr->anchor_call));
 	return (0);
 }
 
-- 
cgit v1.2.3