[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: moot and unposixy error message
From: |
Andreas Schwab |
Subject: |
Re: moot and unposixy error message |
Date: |
Tue, 19 Aug 2008 00:28:44 +0200 |
User-agent: |
Gnus/5.110009 (No Gnus v0.9) Emacs/22.2 (gnu/linux) |
Benno Schulenberg <address@hidden> writes:
> Hi,
>
> In src/od.c around line 1820 it says this:
>
> if (limit_bytes_to_format)
> {
> end_offset = n_bytes_to_skip + max_bytes_to_format;
> if (end_offset < n_bytes_to_skip)
> error (EXIT_FAILURE, 0, _("skip-bytes + read-bytes is too large"));
> }
>
> Since max_bytes_to_format cannot be negative, the second 'if' will
> never trigger, so the whole six lines are moot.
But the sum can overflow, and since the involved types are unsigned this
has defined (wrap-around) behaviour.
> Further, the Open Group says that 'od' should not produce an error
> when '-j' plus '-N' is longer than the file, so the above section
> can be removed.
This is a good point, however. But end_offset should then be set to
(uintmax_t)-1 on overflow.
Andreas.
--
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."