GNU bug report logs - #37585
Undefined behavior in nl, print_lineno

Previous Next

Package: coreutils;

Reported by: Roland Illig <roland.illig <at> gmx.de>

Date: Wed, 2 Oct 2019 14:52:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#37585: closed (Undefined behavior in nl, print_lineno)
Date: Thu, 03 Oct 2019 19:45:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Thu, 3 Oct 2019 12:43:54 -0700
with message-id <cd8a7b78-03c3-8237-c6c7-1b289ddb3ef2 <at> cs.ucla.edu>
and subject line Re: bug#37585: Undefined behavior in nl, print_lineno
has caused the debbugs.gnu.org bug report #37585,
regarding Undefined behavior in nl, print_lineno
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
37585: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=37585
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Roland Illig <roland.illig <at> gmx.de>
To: bug-coreutils <at> gnu.org
Subject: Undefined behavior in nl, print_lineno
Date: Wed, 2 Oct 2019 16:50:53 +0200
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.


[Message part 3 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Roland Illig <roland.illig <at> gmx.de>
Cc: 37585-done <at> debbugs.gnu.org
Subject: Re: bug#37585: Undefined behavior in nl, print_lineno
Date: Thu, 3 Oct 2019 12:43:54 -0700
[Message part 4 (text/plain, inline)]
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.
[0001-cp-simplify-integer-overflow-checking.patch (text/x-patch, attachment)]
[0002-nl-fix-integer-overflow-bug.patch (text/x-patch, attachment)]
[0003-numfmt-avoid-unlikely-integer-overflow.patch (text/x-patch, attachment)]
[0004-truncate-avoid-integer-overflow-assumptions.patch (text/x-patch, attachment)]

This bug report was last modified 5 years and 226 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.