diff options
author | Karel Zak | 2018-02-15 11:58:41 +0100 |
---|---|---|
committer | Karel Zak | 2018-02-15 11:58:41 +0100 |
commit | 19b10b89789943db23131db6eab40706eb915dcc (patch) | |
tree | e401ddca255f098ccd88af945f64d1a5fddaf69d /libsmartcols | |
parent | lscpu-arm: add Faraday And Brahma cores (diff) | |
download | kernel-qcow2-util-linux-19b10b89789943db23131db6eab40706eb915dcc.tar.gz kernel-qcow2-util-linux-19b10b89789943db23131db6eab40706eb915dcc.tar.xz kernel-qcow2-util-linux-19b10b89789943db23131db6eab40706eb915dcc.zip |
libsmartcols: interpret zero width for pending data as error
The command
$ column -t -W2 -c11 <<< "cat dog bird"
causes finite loop, because there is no minimal column width (missing
header). The print functions should be robust enough to return -EINVAL
when nonsense is requested.
Addresses: https://github.com/karelzak/util-linux/pull/577
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols')
-rw-r--r-- | libsmartcols/src/table_print.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c index 5606d23de..b0b5b6c81 100644 --- a/libsmartcols/src/table_print.c +++ b/libsmartcols/src/table_print.c @@ -387,6 +387,8 @@ static int print_pending_data( if (!cl->pending_data) return 0; + if (!width) + return -EINVAL; DBG(COL, ul_debugobj(cl, "printing pending data")); @@ -405,7 +407,8 @@ static int print_pending_data( if (bytes == (size_t) -1) goto err; - step_pending_data(cl, bytes); + if (bytes) + step_pending_data(cl, bytes); if (color) fputs(color, tb->out); |