]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
column: avoid memory overrun and/or use of uninitialized buffer
authorJim Meyering <jim@meyering.net>
Wed, 16 Nov 2011 19:10:39 +0000 (20:10 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 16 Nov 2011 22:51:33 +0000 (23:51 +0100)
* text-utils/column.c (maketbl): Use the right starting point
and the right length when zeroing new memory after xrealloc.

text-utils/column.c

index f8fd350718ca5cc75716df0fd38f1585f05a20bd..79d284221533123d790419f0b6a048ea0879eae6 100644 (file)
@@ -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;
                }