From 26ae00a72b6cfb030a637d7a85ec06afac6f5d1a Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 16 Nov 2011 20:10:39 +0100 Subject: [PATCH] column: avoid memory overrun and/or use of uninitialized buffer * text-utils/column.c (maketbl): Use the right starting point and the right length when zeroing new memory after xrealloc. --- text-utils/column.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/text-utils/column.c b/text-utils/column.c index f8fd350718..79d2842215 100644 --- a/text-utils/column.c +++ b/text-utils/column.c @@ -305,8 +305,8 @@ static void maketbl(wchar_t **list, int entries, wchar_t *separator) cols = xrealloc(cols, maxcols * sizeof(wchar_t *)); lens = xrealloc(lens, maxcols * sizeof(ssize_t)); /* zero fill only new memory */ - memset(lens + ((maxcols - DEFCOLS) * sizeof(ssize_t)), 0, - DEFCOLS * sizeof(int)); + memset(lens + (maxcols - DEFCOLS), 0, + DEFCOLS * sizeof(*lens)); } p = NULL; } -- 2.47.3