From 9af396ad44af25a34fd0abdf77d156fc5ba82d11 Mon Sep 17 00:00:00 2001 From: claudio Date: Thu, 28 Sep 2023 07:01:26 +0000 Subject: [PATCH] Enforce NUL termination of the neighbor shutdown reason sent from bgpctl before calling strlcpy() with that string. OK tb@ some long time ago --- usr.sbin/bgpd/control.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 16195d1e8ca..d163be17512 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.112 2023/08/04 09:20:12 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.113 2023/09/28 07:01:26 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -388,14 +388,20 @@ control_dispatch_msg(struct pollfd *pfd, struct peer_head *peers) control_result(c, CTL_RES_OK); break; case IMSG_CTL_NEIGHBOR_DOWN: - p->conf.down = 1; + neighbor->reason[ + sizeof(neighbor->reason) - 1] = + '\0'; strlcpy(p->conf.reason, neighbor->reason, sizeof(p->conf.reason)); + p->conf.down = 1; session_stop(p, ERR_CEASE_ADMIN_DOWN); control_result(c, CTL_RES_OK); break; case IMSG_CTL_NEIGHBOR_CLEAR: + neighbor->reason[ + sizeof(neighbor->reason) - 1] = + '\0'; strlcpy(p->conf.reason, neighbor->reason, sizeof(p->conf.reason)); -- 2.20.1