bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37585: Undefined behavior in nl, print_lineno


From: Paul Eggert
Subject: bug#37585: Undefined behavior in nl, print_lineno
Date: Thu, 3 Oct 2019 12:43:54 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0

On 10/2/19 7:50 AM, Roland Illig wrote:
The current code says:

   next_line_no = line_no + page_incr;
   if (next_line_no < line_no)
     die (EXIT_FAILURE, 0, _("line number overflow"));

Since intmax_t is a regular integer type, overflow invokes undefined
behavior and must therefore be checked using other means.

Thanks for the bug report. I looked for similar problems involving integer-overflow diagnostics in coreutils and installed the attached patches. The second patch should fix the bug you mentioned.

Attachment: 0001-cp-simplify-integer-overflow-checking.patch
Description: Text Data

Attachment: 0002-nl-fix-integer-overflow-bug.patch
Description: Text Data

Attachment: 0003-numfmt-avoid-unlikely-integer-overflow.patch
Description: Text Data

Attachment: 0004-truncate-avoid-integer-overflow-assumptions.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]