From: Paul Eggert Date: Sat, 28 Jun 2025 15:15:42 +0000 (-0700) Subject: od: fix theoretical size_t malloc overflow X-Git-Tag: v9.8~283 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0d1c25d1cb6d0ce119775368a0fabc7644393f6e;p=thirdparty%2Fcoreutils.git od: fix theoretical size_t malloc overflow * src/od.c (dump, dump_strings): Use idx_t allocators rather than size_t allocators, to avoid unchecked integer overflow on theoretical platforms where SIZE_MAX < IDX_MAX. --- diff --git a/src/od.c b/src/od.c index 6b5c8675f1..7306b0f9ad 100644 --- a/src/od.c +++ b/src/od.c @@ -1432,7 +1432,7 @@ dump (void) bool ok = true; size_t n_bytes_read; - block[0] = xnmalloc (2, bytes_per_block); + block[0] = xinmalloc (2, bytes_per_block); block[1] = block[0] + bytes_per_block; current_offset = n_bytes_to_skip; @@ -1514,7 +1514,7 @@ static bool dump_strings (void) { idx_t bufsize = MAX (100, string_min + 1); - char *buf = xmalloc (bufsize); + char *buf = ximalloc (bufsize); uintmax_t address = n_bytes_to_skip; bool ok = true;