Subject: Re: bug#78880: od Heap-buffer overflow

From: Jim Meyering <[email-masked]>
Date: Sun, 29 Jun 2025 09:21:39 -0700

On Sat, Jun 28, 2025 at 9:25 PM Paul Eggert <[email-masked]> wrote:
> On 2025-06-24 18:31, Jim Meyering wrote:
> > That goes way back. I think od.c
> > was the second stand-alone program I contributed to coreutils (first
> > was tr). The earliest email I still have that mentions it is from
> > 1997-01 prior to textutils-1.22, but that was just a ChangeLog entry
> > about adapting to a changed strtod API.
>
> I have a soft spot for 'od' as I remember using it in Unix in the 1970s.
> So I looked for nearby bugs and found a few, mostly integer overflows. I
> installed the attached patches to refactor the source and to fix the
> bugs I found.
>
> You might be amused by patch 0007, which fixes a POSIX conformance bug
> introduced in January 1995, in what is now Git commit
> 851162a0da41f2b6b08a8c1ed045086db9a443a0. Evidently this POSIX-required
> feature is not often used! The NEWS item in the fix says "[bug
> introduced on 1995-01-25]" instead of the usual "[bug introduced in
> coreutils-N]" comment because I don't know how to relate that commit to
> a version number (would it be textutils? probably doesn't matter).
>
> You might also be amused (or appalled) by patch 0007's hacky fix. I
> couldn't bestir myself to write a cleaner fix. The hacky fix doesn't
> require memory allocation so in some sense it's better than a cleaner
> one would be.

Hi Paul,

Wow. Thanks for all of those fixes (haven't looked at all of them yet).
As for how to determine which release has the fix from your 0007 patch,
that commit was after textutils-1.8b, and the following release was
textutils-2.0:

$ git desc 851162a0da41f2b6b08a8c1ed045086db9a443a0
TEXTUTILS-1_8b-499-g851162a0d
$ git tag |grep -A1 1.8b
TEXTUTILS-1_8b
TEXTUTILS-2_0

I'm not appalled :-)
It feels like accommodating the old format sort of justifies the hackiness.