Re: moot and unposixy error message
Andreas Schwab wrote: But the sum can overflow, and since the involved types are unsigned this has defined (wrap-around) behaviour. Thanks. I felt I must be overlooking something, but couldn't figure out what. 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. Setting end_offset to the largest possible integer upon overflow will probably do the right thing in all practical cases; but if the file is really longer than an integer can represent, it would then output the wrong number of bytes. Better print an error message instead then. $ od -j1 -N18446744073709551615 testfile od: skip-bytes + read-bytes is too large $ od -j1 -N18446744073709551616 testfile od: -N argument `18446744073709551616' too large $ od -j18446744073709551616 -N1 testfile od: -j argument `18446744073709551616' too large $ od -j18446744073709551615 -N1 testmail.k od: skip-bytes + read-bytes is too large Benno ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
moot and unposixy error message
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. 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. http://www.opengroup.org/onlinepubs/7990989775/xcu/od.html -- If count bytes of input (after successfully skipping, if -j skip is specified) are not available, it will not be considered an error; the od utility will format the input that is available. Benno ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
Re: moot and unposixy error message
Benno Schulenberg [EMAIL PROTECTED] 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, [EMAIL PROTECTED] 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. ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils