From 24f08a61e6456fb2bdf1382000a0b4b3bf910d45 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 17 Sep 2020 23:31:28 +0000 Subject: Add stralloc_readyplus_tuned, fix overflow on stralloc_readyplus --- src/libstddjb/stralloc_readyplus_tuned.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/libstddjb/stralloc_readyplus_tuned.c (limited to 'src/libstddjb') diff --git a/src/libstddjb/stralloc_readyplus_tuned.c b/src/libstddjb/stralloc_readyplus_tuned.c new file mode 100644 index 0000000..f00813f --- /dev/null +++ b/src/libstddjb/stralloc_readyplus_tuned.c @@ -0,0 +1,12 @@ +/* ISC license. */ + +#include +#include + +int stralloc_readyplus_tuned (stralloc *sa, size_t n, size_t base, size_t a, size_t b) +{ + size_t newlen = sa->len + n ; + return newlen < sa->len ? + (errno = ERANGE, 0) : + stralloc_ready_tuned(sa, newlen, base, a, b) ; +} -- cgit v1.2.3