Opened 2 weeks ago
#413 new defect
Bugs identified in archive_util_.pl1
| Reported by: | Jim Lippard | Owned by: | Eric Swenson |
|---|---|---|---|
| Priority: | major | Milestone: | MR12.9 |
| Component: | Standard Library | Version: | MR12.9 |
| Keywords: | archive, archive_util_.pl1 | Cc: |
Description
archive_util_ accepts archives that archive_ rejects, so the archive command and the archive_ subroutine disagree about what an archive is: the command lists and processes damaged archives that the subroutine calls format errors. It also has precision and declaration errors. Numbers 20–27 are part of a single numbering across the archive programs; line numbers are those of the MR12.8 source. The crafted archives named below are in the test kit (tests.archive), with an exec_com for each item marked "Test".
Bug 20: headers beginning with the obsolete archive_data_$header_begin are accepted, line 71
A header may begin with either archive_data_$ident or the obsolete archive_data_$header_begin. archive_ accepts only archive_data_$ident. An archive whose first header uses the obsolete string lists without error:
ac tl t_obsolete (lists alpha and beta)
Expected: "Format error", as from archive_. (No archive using the obsolete string is known to exist.) Test: bug20.ec.
Bug 21: the header fence (archive_data_$fence) is not checked, line 71
A header whose fence is damaged is accepted:
ac tl t_nofence (lists alpha and beta; beta's fence is damaged)
Expected: alpha is listed, then "Format error", as from archive_. Test: bug21.ec.
Bug 22: the bit count field is not validated, lines 61 and 121
The bit count field is converted with cv_dec_ with no check, so a field that is not a number is taken as some value (possibly 0), and the scan continues at the wrong place, possibly treating component data as the next header:
ac tl t_badbc
alpha 09/22/26 1639.0 r w 09/22/26 1630.0 x
beta ...
Expected: "Format error"; the field must be digits (left or right justified, as archive_ allows), and the component must lie within the archive. Test: bug22.ec.
Bug 23: an archive whose bit count is not a whole number of words is accepted until its end, line 92
The archive's length is rounded up to a whole word, so its components are listed or processed before a format error is reported at the end:
ac tl t_unaligned (t_ok plus one character)
alpha ...
beta ...
archive: Format error in ...>t_unaligned.archive
Expected: "Format error" at the start, with nothing listed or processed. Test: bug23.ec.
Bug 24: a header that extends past the end of the archive is read, line 69
When 1 to 24 words remain after a component, the next header is read partly beyond the archive's bit count. Normally this produces a format error anyway. Found by inspection.
Bug 25: offsets are computed with 17-bit precision, lines 36 and 61
Word offsets and the archive length are held as fixed bin (17) and computed with divide (..., 17, 0), limiting them to 131,071 words, while a segment can be 262,144 words. An offset derived from a corrupt bit count can also wrap around the segment, since it is not checked against the archive length before a pointer is formed. No failure was seen in tests on MR12.8 with archives over 128K words. Found by inspection.
Bug 26: first_disected returns component outputs along with an error code, line 112
On a status error or an empty archive, the segment pointer, name and bit count outputs are filled from whatever the header pointer addresses. Expected: outputs cleared whenever the code is nonzero. Found by inspection.
Bug 27: incorrect declarations, lines 34, 40, 103 and 135
hcs_$status_mins is declared with fixed bin (17) type and code arguments (actual: fixed bin (2) and fixed bin (35)); the error code parameters are fixed bin (17), though a full error_table_ code can be returned in them when the archive's status cannot be obtained; cv_dec_ is declared as a subroutine rather than a function. Found by inspection.
