From 0d1c25d1cb6d0ce119775368a0fabc7644393f6e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 28 Jun 2025 08:15:42 -0700 Subject: [PATCH] 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. --- src/od.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; -- 2.47.3