]> git.ipfire.org Git - thirdparty/coreutils.git/commit
ptx: fix infinite loop with -G and a narrow output width master
authorAyesha Shafique <ayeshashafique123@gmail.com>
Mon, 27 Jul 2026 07:03:19 +0000 (02:03 -0500)
committerPádraig Brady <P@draigBrady.com>
Tue, 28 Jul 2026 11:05:32 +0000 (12:05 +0100)
commit04befb136a7f1c50b18be322995f3a2906d41e74
tree198f62562e42434b00fbdf563cb07451ee76709a
parent114aa7f1b785ceb4a0b4aa951cdfc74132cc59d1
ptx: fix infinite loop with -G and a narrow output width

With GNU extensions disabled, before_max_width can go negative, and
define_all_fields then loops forever trying to shrink the before field
to a width narrower than empty:

  $ printf 'qux\n' | src/ptx -G -w2
  [hangs]

Commit v6.12-96-g773be9eca added a clamp for this, but placed it in
the GNU-extensions branch only.  Move it after that if/else so that
both branches are covered.

* src/ptx.c (fix_output_parameters): Clamp before_max_width for both
the GNU and non-GNU cases.
* tests/ptx/ptx-overrun.sh: Add a test case.
* NEWS: Mention the bug fix.
Fixes https://bugs.gnu.org/81507
NEWS
src/ptx.c
tests/ptx/ptx-overrun.sh