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>
This commit is contained in:
parent
dd9b4cb320
commit
19b10b8978
|
@ -387,6 +387,8 @@ static int print_pending_data(
|
||||||
|
|
||||||
if (!cl->pending_data)
|
if (!cl->pending_data)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (!width)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
DBG(COL, ul_debugobj(cl, "printing pending data"));
|
DBG(COL, ul_debugobj(cl, "printing pending data"));
|
||||||
|
|
||||||
|
@ -405,7 +407,8 @@ static int print_pending_data(
|
||||||
if (bytes == (size_t) -1)
|
if (bytes == (size_t) -1)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
step_pending_data(cl, bytes);
|
if (bytes)
|
||||||
|
step_pending_data(cl, bytes);
|
||||||
|
|
||||||
if (color)
|
if (color)
|
||||||
fputs(color, tb->out);
|
fputs(color, tb->out);
|
||||||
|
|
Loading…
Reference in New Issue