瀏覽代碼

Merge pull request #3868 from 1uptalent/3867-allow-pax-global-extended-headers-to-passthrough

FIX 3867 allow pax global extended headers to passthrough
Guillaume J. Charmes 11 年之前
父節點
當前提交
f9b4146ad4
共有 2 個文件被更改,包括 16 次插入0 次删除
  1. 4 0
      archive/archive.go
  2. 12 0
      archive/archive_test.go

+ 4 - 0
archive/archive.go

@@ -228,6 +228,10 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader *tar.Reader)
 			return err
 		}
 
+	case tar.TypeXGlobalHeader:
+		utils.Debugf("PAX Global Extended Headers found and ignored")
+		return nil
+
 	default:
 		return fmt.Errorf("Unhandled tar header type %d\n", hdr.Typeflag)
 	}

+ 12 - 0
archive/archive_test.go

@@ -1,6 +1,7 @@
 package archive
 
 import (
+	"archive/tar"
 	"bytes"
 	"fmt"
 	"io"
@@ -124,3 +125,14 @@ func TestTarUntar(t *testing.T) {
 		}
 	}
 }
+
+// Some tar archives such as http://haproxy.1wt.eu/download/1.5/src/devel/haproxy-1.5-dev21.tar.gz
+// use PAX Global Extended Headers.
+// Failing prevents the archives from being uncompressed during ADD
+func TestTypeXGlobalHeaderDoesNotFail(t *testing.T) {
+	hdr := tar.Header{Typeflag: tar.TypeXGlobalHeader}
+	err := createTarFile("pax_global_header", "some_dir", &hdr, nil)
+	if err != nil {
+		t.Fatal(err)
+	}
+}