[openssh-commits] [openssh] 35/87: upstream: grow destination buffer more aggressively to avoid bad
git+noreply at mindrot.org
git+noreply at mindrot.org
Fri Oct 30 20:21:12 AEDT 2026
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit 07e9138c87f6297739484ab703fafa475871f736
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Fri Oct 30 03:40:56 2026 +0000
upstream: grow destination buffer more aggressively to avoid bad
worst-case behaviour when lots of characters that need escaping are processed
Anthropic ANT-2026-P8BKU1E3
OpenBSD-Commit-ID: 864b76c7cd9c91c9a2b692e93d99b1ce0b0d32c3
---
utf8.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/utf8.c b/utf8.c
index c2cd02b67..e30d78fb6 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utf8.c,v 1.11 2020/05/01 06:28:52 djm Exp $ */
+/* $OpenBSD: utf8.c,v 1.12 2026/10/30 03:40:56 djm Exp $ */
/*
* Copyright (c) 2016 Ingo Schwarze <schwarze at openbsd.org>
*
@@ -77,7 +77,12 @@ grow_dst(char **dst, size_t *sz, size_t maxsz, char **dp, size_t need)
if (*dp + need < *dst + *sz)
return 0;
- tsz = *sz + 128;
+ /*
+ * Grow geometrically to avoid recallocarray repeatedly having to
+ * copy its buffer as the allocation grows.
+ * Note: maxsz is always <=INT_MAX so we can't overflow the size_t;
+ */
+ tsz = *sz + (*sz > 128 ? *sz : 128);
if (tsz > maxsz)
tsz = maxsz;
if ((tp = recallocarray(*dst, *sz, tsz, 1)) == NULL)
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list