From: Paul Eggert Date: Tue, 27 Apr 2021 03:04:19 +0000 (-0700) Subject: csplit: size_t overflow check X-Git-Tag: v9.0~117 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=852794283564e2ac05162f0826fd67da1a6e2c3e;p=thirdparty%2Fcoreutils.git csplit: size_t overflow check * src/csplit.c (get_new_buffer): Fix unlikely size_t overflow. --- 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);