From 852794283564e2ac05162f0826fd67da1a6e2c3e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 26 Apr 2021 20:04:19 -0700 Subject: [PATCH] csplit: size_t overflow check * src/csplit.c (get_new_buffer): Fix unlikely size_t overflow. --- src/csplit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/csplit.c b/src/csplit.c index 79bd034e3f..f188e88940 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -416,7 +416,8 @@ get_new_buffer (size_t min_size) if (alloc_size < min_size) { size_t s = min_size - alloc_size + INCR_SIZE - 1; - alloc_size += s - s % INCR_SIZE; + if (INT_ADD_WRAPV (alloc_size, s - s % INCR_SIZE, &alloc_size)) + xalloc_die (); } new_buffer = create_new_buffer (alloc_size); -- 2.47.2