From d6e113dfa131ed9e29c9bdc82fd6ac01a2cad7ac Mon Sep 17 00:00:00 2001 From: claudio Date: Fri, 27 Mar 2020 12:46:00 +0000 Subject: Use the correct math to calculate how many bytes are needed for b64_pton(). The size is first rounded up in case where the input string length is not a multiple of 4. Reported by kristaps@ --- usr.sbin/rpki-client/tal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/rpki-client/tal.c b/usr.sbin/rpki-client/tal.c index b5e8f5b2963..d66cdba9d04 100644 --- a/usr.sbin/rpki-client/tal.c +++ b/usr.sbin/rpki-client/tal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tal.c,v 1.16 2019/11/29 17:29:28 benno Exp $ */ +/* $OpenBSD: tal.c,v 1.17 2020/03/27 12:46:00 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -107,7 +107,7 @@ tal_parse_buffer(const char *fn, char *buf) } /* Now the BASE64-encoded public key. */ - sz = ((sz + 2) / 3) * 4 + 1; + sz = ((sz + 3) / 4) * 3 + 1; if ((b64 = malloc(sz)) == NULL) err(1, NULL); if ((b64sz = b64_pton(buf, b64, sz)) < 0) -- cgit v1.2.3-59-g8ed1b