Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_header_int: allow leading spaces #116

Merged
merged 4 commits into from
Jun 4, 2021
Merged

Conversation

StefanKarpinski
Copy link
Member

@StefanKarpinski StefanKarpinski commented Jun 2, 2021

There are a number of changes in this PR, but the main one is the fix for #111 which is to allow leading spaces in integer fields since some old tar programs emitted these fields that way (contrary to the spec). The other substantial change is improved checking and reporting of errors in headers. Here is the list of all changes:

  • read_header_int: allow leading spaces (fix Incorrect header checksum error #111)
  • rename header_view => data
  • read_standard_header: improve error checks & messages
  • read_header_size: avoid modifying buffer & try/catch

@codecov
Copy link

codecov bot commented Jun 2, 2021

Codecov Report

Merging #116 (45197a8) into master (343e923) will increase coverage by 0.79%.
The diff coverage is 98.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #116      +/-   ##
==========================================
+ Coverage   96.05%   96.84%   +0.79%     
==========================================
  Files           4        4              
  Lines         684      729      +45     
==========================================
+ Hits          657      706      +49     
+ Misses         27       23       -4     
Impacted Files Coverage Δ
src/extract.jl 97.97% <98.66%> (+1.39%) ⬆️
src/create.jl 97.19% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 343e923...45197a8. Read the comment docs.

@StefanKarpinski StefanKarpinski force-pushed the sk/checksum branch 3 times, most recently from 2443d4e to 3175c90 Compare June 4, 2021 12:43
Some old versions of `tar` (e.g. Solaris) emitted integer fields with
leadings *spaces* which is technically contrary to the standard, but
seems harmless to support. This adds a fragment of this tarball:

    https://sparse.tamu.edu/MM/Oberwolfach/LF10.tar.gz

This is a collection of example sparse matrix files. The fragment is a
single header entry followed by one block of data and is a valid tarball
by itself with the idiosyncratic field formatting of Solaris `tar`.
This is a fairly significant refactoring of the error checking aspect of
header parsing with a few high-level improvements. The first major
improvement is that this now extracts and checks the version string
first, then the checksum and only if those are valid does it try
extracting any other fields. This makes the error message a bit clearer:
previously you would get a cryptic complaint about an invalid octal
digit if you tried to parse something that wasn't a tar file, now at
least you get an "invalid version string for tar file" error.

This now also dumps the entire header data if there is any error parsing
the header, which helps with diagnosis. In addition, the error checking
and reporting for boundary conditions in fields which can be malformed
(i.e. octal integers) is much improved.

Last but not least, the test coverage of all of this is much increased.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect header checksum error
1 participant