bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] [PATCH] improved error messages when reading snapshot file


From: Nathan Stratton Treadway
Subject: [Bug-tar] [PATCH] improved error messages when reading snapshot file
Date: Tue, 1 Jan 2013 23:39:11 -0500
User-agent: Mutt/1.5.20 (2009-06-14)

On Sat, Dec 22, 2012 at 20:43:16 -0800, Paul Eggert wrote:
> * src/incremen.c (read_incr_db_01, write_directory_file_entry):
> Allow negative time_t, dev_t, and ino_t.

On Sat, Dec 22, 2012 at 22:31:12 -0800, Paul Eggert wrote:
> * src/incremen.c (read_unsigned_num): Last arg is intmax_t *, not
> uintmax_t, for consistency with other readers.  All callers changed.
> Avoid signed integer overflow.
> (read_num):

The attached patch builds on those changes to incremen.c, proposing a
way to extend the error messages generated when reading and parsing the
fields in the snapshot file fails for some reason.

Unfortunately the name of the directory entry associated with an
invalid field isn't known at the time that field is being read, so we
can't give the user that information in the error message.  Instead, we
print what we do have available: the name of the snapshot file, the
exact type of error that was detected, a hint of the context (e.g.
characters read just before the error) when available, and finally the
name of the field being read and the the current byte position in the
input file.

Here's some sample messages generated with this patch in place (covering
most of the different conditions that might be detected):

================
./tar: snaptest0: Field too long while reading snapshot file:
   after reading "12345678901234567890" [field "tv_sec" at byte 36]
./tar: Error is not recoverable: exiting now

./tar: snaptest1: Unexpected EOF in snapshot file:
   after reading "98765432" [field "tv_nsec" at byte 40]
./tar: Error is not recoverable: exiting now

./tar: snaptest2: Unexpected field value in snapshot file:
   non-numeric character 0x78 found after reading "6336301" [field "tv_nsec" at 
byte 160]
./tar: Error is not recoverable: exiting now

./tar: snaptest3: Unexpected field value in snapshot file:
   strtoumax failed on value "99999999999999999999" [field "dev" at byte 142]: 
Numerical result out of range
./tar: Error is not recoverable: exiting now

./tar: snaptest4: Unexpected field value in snapshot file:
   strtoimax failed on value "-9999999999999999999" [field "dev" at byte 142]: 
Numerical result out of range
./tar: Error is not recoverable: exiting now

./tar: snaptest5: Unexpected field value in snapshot file:
   value "-2306" below min 0 [field "dev" at byte 166]
./tar: Error is not recoverable: exiting now

./tar: snaptest6: Unexpected field value in snapshot file:
   value "9223372036854775899" exceeds max 4294967295 [field "tv_sec" at byte 
160]
./tar: Error is not recoverable: exiting now

./tar: snaptest7: Missing record terminator:
   at end of dumpdir data [field "dircontents" at byte 206]
./tar: Error is not recoverable: exiting now

./tar: snaptest8: Unexpected EOF in snapshot file:
   at start of new field [field "?" at byte 173]
./tar: Error is not recoverable: exiting now

./tar: snaptest9: Unexpected EOF in snapshot file:
   at start of field [field "tv_nsec" at byte 46]
./tar: Error is not recoverable: exiting now
================

(I preserved the existing gettext strings, but didn't see any simple way
to factor out the common "[field \"%s\" at byte %s]" substring or
otherwise simplify the newly-created strings, since they are all part of
the the format masks.)

                                                        Nathan

----------------------------------------------------------------------------
Nathan Stratton Treadway  -  address@hidden  -  Mid-Atlantic region
Ray Ontko & Co.  -  Software consulting services  -   http://www.ontko.com/
 GPG Key: http://www.ontko.com/~nathanst/gpg_key.txt   ID: 1023D/ECFB6239
 Key fingerprint = 6AD8 485E 20B9 5C71 231C  0C32 15F3 ADCD ECFB 6239

Attachment: incremen.c_improved_snapshot_error_messages.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]