From e966ab902416b0cd0b8ed2c3734bf4956e68c211 Mon Sep 17 00:00:00 2001 From: claudio Date: Thu, 16 Dec 2021 09:33:56 +0000 Subject: [PATCH] When adding the extra 10% of space to a needed sysctl buffer use math that is less likely to overflow the int type used. A BGP fullfeed is now so big that this calculation overflowed and then got sign extended. The result was for example 'route -n show' failures. Problem identified with deraadt@ OK deraadt@ (more cleanup needed but this fix is a good start) --- sys/net/rtsock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index a717d112eb9..b35beb260eb 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.322 2021/09/14 09:15:55 mvs Exp $ */ +/* $OpenBSD: rtsock.c,v 1.323 2021/12/16 09:33:56 claudio Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -2219,7 +2219,7 @@ sysctl_rtable(int *name, u_int namelen, void *where, size_t *given, void *new, if (*given < w.w_needed) return (ENOMEM); } else - *given = (11 * w.w_needed) / 10; + *given = w.w_needed + w.w_needed / 10; return (error); } -- 2.20.1