From: claudio Date: Thu, 28 Sep 2023 07:01:26 +0000 (+0000) Subject: Enforce NUL termination of the neighbor shutdown reason sent from X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9af396ad44af25a34fd0abdf77d156fc5ba82d11;p=openbsd Enforce NUL termination of the neighbor shutdown reason sent from bgpctl before calling strlcpy() with that string. OK tb@ some long time ago --- 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));