summaryrefslogtreecommitdiffstats
path: root/text-utils/column.c
diff options
context:
space:
mode:
authorJim Meyering2011-11-16 20:10:39 +0100
committerKarel Zak2011-11-16 23:51:33 +0100
commit26ae00a72b6cfb030a637d7a85ec06afac6f5d1a (patch)
tree8371df010bb80a35d5477b788b85bd290b4fddc9 /text-utils/column.c
parentprlimit: don't share pointer for old and new in prlimit(2) (diff)
downloadkernel-qcow2-util-linux-26ae00a72b6cfb030a637d7a85ec06afac6f5d1a.tar.gz
kernel-qcow2-util-linux-26ae00a72b6cfb030a637d7a85ec06afac6f5d1a.tar.xz
kernel-qcow2-util-linux-26ae00a72b6cfb030a637d7a85ec06afac6f5d1a.zip
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.
Diffstat (limited to 'text-utils/column.c')
-rw-r--r--text-utils/column.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/text-utils/column.c b/text-utils/column.c
index f8fd35071..79d284221 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;
}