mirror of
https://github.com/openssh/openssh-portable.git
synced 2026-11-06 05:16:43 +00:00
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
This commit is contained in:
1 parent
e7b23fc20f
commit
07e9138c87
1 file changed
+7
-2
@@ -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@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)
|
||||
|
||||
Reference in new issue
Block a user