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


Message #10 received at 37585-done <at> debbugs.gnu.org (full text, mbox):

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 1 (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.