"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/archive/tar/reader.go" between
moby-20.10.7.tar.gz and moby-20.10.8.tar.gz

About: Moby is a framework to assemble specialized container systems (formerly project name Docker; see here to clarify the relationship between the projects).

reader.go  (moby-20.10.7):reader.go  (moby-20.10.8)
// Copyright 2009 The Go Authors. All rights reserved. // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package tar package tar
import ( import (
"bytes" "bytes"
"io" "io"
"io/ioutil"
"strconv" "strconv"
"strings" "strings"
"time" "time"
) )
// Reader provides sequential access to the contents of a tar archive. // Reader provides sequential access to the contents of a tar archive.
// Reader.Next advances to the next file in the archive (including the first), // Reader.Next advances to the next file in the archive (including the first),
// and then Reader can be treated as an io.Reader to access the file's data. // and then Reader can be treated as an io.Reader to access the file's data.
type Reader struct { type Reader struct {
r io.Reader r io.Reader
skipping to change at line 107 skipping to change at line 106
Name: hdr.Name, Name: hdr.Name,
Typeflag: hdr.Typeflag, Typeflag: hdr.Typeflag,
Xattrs: hdr.Xattrs, Xattrs: hdr.Xattrs,
PAXRecords: hdr.PAXRecords, PAXRecords: hdr.PAXRecords,
Format: format, Format: format,
}, nil }, nil
} }
continue // This is a meta header affecting the next head er continue // This is a meta header affecting the next head er
case TypeGNULongName, TypeGNULongLink: case TypeGNULongName, TypeGNULongLink:
format.mayOnlyBe(FormatGNU) format.mayOnlyBe(FormatGNU)
realname, err := ioutil.ReadAll(tr) realname, err := io.ReadAll(tr)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var p parser var p parser
switch hdr.Typeflag { switch hdr.Typeflag {
case TypeGNULongName: case TypeGNULongName:
gnuLongName = p.parseString(realname) gnuLongName = p.parseString(realname)
case TypeGNULongLink: case TypeGNULongLink:
gnuLongLink = p.parseString(realname) gnuLongLink = p.parseString(realname)
skipping to change at line 297 skipping to change at line 296
return ErrHeader return ErrHeader
} }
} }
hdr.PAXRecords = paxHdrs hdr.PAXRecords = paxHdrs
return nil return nil
} }
// parsePAX parses PAX headers. // parsePAX parses PAX headers.
// If an extended header (type 'x') is invalid, ErrHeader is returned // If an extended header (type 'x') is invalid, ErrHeader is returned
func parsePAX(r io.Reader) (map[string]string, error) { func parsePAX(r io.Reader) (map[string]string, error) {
buf, err := ioutil.ReadAll(r) buf, err := io.ReadAll(r)
if err != nil { if err != nil {
return nil, err return nil, err
} }
sbuf := string(buf) sbuf := string(buf)
// For GNU PAX sparse format 0.0 support. // For GNU PAX sparse format 0.0 support.
// This function transforms the sparse format 0.0 headers into format 0.1 // This function transforms the sparse format 0.0 headers into format 0.1
// headers since 0.0 headers were not PAX compliant. // headers since 0.0 headers were not PAX compliant.
var sparseMap []string var sparseMap []string
skipping to change at line 436 skipping to change at line 435
// In order to continue reading tar files created by form er, buggy // In order to continue reading tar files created by form er, buggy
// versions of Go, we skeptically parse the atime and cti me fields. // versions of Go, we skeptically parse the atime and cti me fields.
// If we are unable to parse them and the prefix field lo oks like // If we are unable to parse them and the prefix field lo oks like
// an ASCII string, then we fallback on the pre-Go1.8 beh avior // an ASCII string, then we fallback on the pre-Go1.8 beh avior
// of treating these fields as the USTAR prefix field. // of treating these fields as the USTAR prefix field.
// //
// Note that this will not use the fallback logic for all possible // Note that this will not use the fallback logic for all possible
// files generated by a pre-Go1.8 toolchain. If the gener ated file // files generated by a pre-Go1.8 toolchain. If the gener ated file
// happened to have a prefix field that parses as valid // happened to have a prefix field that parses as valid
// atime and ctime fields (e.g., when they are valid octa l strings), // atime and ctime fields (e.g., when they are valid octa l strings),
// then it is impossible to distinguish between an valid GNU file // then it is impossible to distinguish between a valid G NU file
// and an invalid pre-Go1.8 file. // and an invalid pre-Go1.8 file.
// //
// See https://golang.org/issues/12594 // See https://golang.org/issues/12594
// See https://golang.org/issues/21005 // See https://golang.org/issues/21005
if p2.err != nil { if p2.err != nil {
hdr.AccessTime, hdr.ChangeTime = time.Time{}, tim e.Time{} hdr.AccessTime, hdr.ChangeTime = time.Time{}, tim e.Time{}
ustar := tr.blk.USTAR() ustar := tr.blk.USTAR()
if s := p.parseString(ustar.Prefix()); isASCII(s) { if s := p.parseString(ustar.Prefix()); isASCII(s) {
prefix = s prefix = s
} }
skipping to change at line 853 skipping to change at line 852
if pos1 >= 0 && err == nil { if pos1 >= 0 && err == nil {
// Seek seems supported, so perform the real Seek. // Seek seems supported, so perform the real Seek.
pos2, err := sr.Seek(n-1, io.SeekCurrent) pos2, err := sr.Seek(n-1, io.SeekCurrent)
if pos2 < 0 || err != nil { if pos2 < 0 || err != nil {
return err return err
} }
seekSkipped = pos2 - pos1 seekSkipped = pos2 - pos1
} }
} }
copySkipped, err := io.CopyN(ioutil.Discard, r, n-seekSkipped) copySkipped, err := io.CopyN(io.Discard, r, n-seekSkipped)
if err == io.EOF && seekSkipped+copySkipped < n { if err == io.EOF && seekSkipped+copySkipped < n {
err = io.ErrUnexpectedEOF err = io.ErrUnexpectedEOF
} }
return err return err
} }
 End of changes. 5 change blocks. 
5 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)