file/untar: allow leading as well as trailing blanks (#2553)
Some really old tar files can have both leading and trailing blanks (nul/space characters) in the same octal number field in the header.
This commit is contained in:
parent
683492f6fe
commit
1600bc5dc6
|
@ -212,6 +212,12 @@
|
|||
#f]
|
||||
[else
|
||||
;; traditional:
|
||||
(define skip-head
|
||||
(or (for/or ([i (in-range len)])
|
||||
(case (integer->char (bytes-ref bstr i))
|
||||
[(#\space #\nul) #f]
|
||||
[else i]))
|
||||
(error 'untar "bad number ~e at ~a" bstr (file-position in))))
|
||||
(define skip-tail
|
||||
(- len
|
||||
(or (for/or ([i (in-range len 0 -1)])
|
||||
|
@ -219,7 +225,7 @@
|
|||
[(#\space #\nul) #f]
|
||||
[else i]))
|
||||
(error 'untar "bad number ~e at ~a" bstr (file-position in)))))
|
||||
(for/fold ([v 0]) ([i (in-range (- len skip-tail))])
|
||||
(for/fold ([v 0]) ([i (in-range skip-head (- len skip-tail))])
|
||||
(define b (bytes-ref bstr i))
|
||||
(if (<= (char->integer #\0) b (char->integer #\7))
|
||||
(+ (* v 8) (- b (char->integer #\0)))
|
||||
|
|
Loading…
Reference in New Issue
Block a user