From: B Watson Date: Tue, 14 Aug 2012 16:27:09 +0000 (+0200) Subject: column: --separator segfaults X-Git-Tag: v2.22-rc2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43f8915c51f1b36c3d1d79d06d58ea5fb27a6cca;p=thirdparty%2Futil-linux.git column: --separator segfaults The --separator and --columns long options in util-linux-2.21.2 and in a git clone from 5 minutes ago, don't work: $ echo foobar | column -s x foobar $ echo foobar | column -c 10 foobar $ echo foobar | column --separator=x column: option '--separator' doesn't allow an argument $ echo foobar | column --separator x Segmentation fault $ echo foobar | column --columns 10 column: bad columns width value: '(null)': Invalid argument $ echo foobar | column --columns=10 column: option '--columns' doesn't allow an argument Looks like a simple case of missing has_arg flag in the "struct option" initialization for these two options. The patch just adds the flag. I haven't done thorough testing of the patched code, but it seems to work OK and it no longer segfaults or tries to dereference a null pointer. Signed-off-by: Karel Zak --- diff --git a/text-utils/column.c b/text-utils/column.c index aab9187ea5..f33cc1447b 100644 --- a/text-utils/column.c +++ b/text-utils/column.c @@ -121,9 +121,9 @@ int main(int argc, char **argv) { { "help", 0, 0, 'h' }, { "version", 0, 0, 'V' }, - { "columns", 0, 0, 'c' }, + { "columns", 1, 0, 'c' }, { "table", 0, 0, 't' }, - { "separator", 0, 0, 's' }, + { "separator", 1, 0, 's' }, { "fillrows", 0, 0, 'x' }, { NULL, 0, 0, 0 }, };