Adding upstream version 3.5.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e37d4622a7
commit
097626e61a
57 changed files with 6023 additions and 0 deletions
BIN
testdata/corpus/already-compressed.jpg
vendored
Normal file
BIN
testdata/corpus/already-compressed.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
2
testdata/corpus/proverbs/extra/proverb3.txt
vendored
Normal file
2
testdata/corpus/proverbs/extra/proverb3.txt
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
"interface{} says nothing."
|
||||
- Rob Pike
|
2
testdata/corpus/proverbs/proverb1.txt
vendored
Normal file
2
testdata/corpus/proverbs/proverb1.txt
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
"Channels orchestrate; mutexes serialize."
|
||||
- Rob Pike
|
2
testdata/corpus/proverbs/proverb2.txt
vendored
Normal file
2
testdata/corpus/proverbs/proverb2.txt
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
"A little copying is better than a little dependency."
|
||||
- Rob Pike
|
2
testdata/corpus/quote1.txt
vendored
Normal file
2
testdata/corpus/quote1.txt
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
"Go has generics; they're called interfaces."
|
||||
- Matt Holt
|
74
testdata/create-evil-tar.go
vendored
Normal file
74
testdata/create-evil-tar.go
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create a file to write our archive to.
|
||||
tarname := "double-evil.tar"
|
||||
fw, err := os.Create(tarname)
|
||||
if nil != err {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Create a new tar archive.
|
||||
tw := tar.NewWriter(fw)
|
||||
|
||||
// Write the evil symlink, it points outside of the target directory
|
||||
hdr := &tar.Header{
|
||||
Name: "bad/file.txt",
|
||||
Mode: 0644,
|
||||
Typeflag: tar.TypeSymlink,
|
||||
Linkname: "../../badfile.txt",
|
||||
ModTime: time.Now(),
|
||||
}
|
||||
if err := tw.WriteHeader(hdr); err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Write safe files to the archive.
|
||||
var files = []struct {
|
||||
Name, Body string
|
||||
}{
|
||||
{"goodfile.txt", "hello world"},
|
||||
{"morefile.txt", "hello world"},
|
||||
{"bad/file.txt", "Mwa-ha-ha"},
|
||||
}
|
||||
for _, file := range files {
|
||||
hdr := &tar.Header{
|
||||
Name: file.Name,
|
||||
Mode: 0644,
|
||||
Size: int64(len(file.Body)),
|
||||
ModTime: time.Now(),
|
||||
}
|
||||
|
||||
if err := tw.WriteHeader(hdr); err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := tw.Write([]byte(file.Body)); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Close the in-memory archive so that it writes trailing data
|
||||
err = tw.Close()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Wrote %s\n", tarname)
|
||||
|
||||
// close the on-disk archive so that it flushes all bytes
|
||||
if err = fw.Close(); err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
}
|
75
testdata/create-evil-zip.go
vendored
Normal file
75
testdata/create-evil-zip.go
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/klauspost/compress/zip"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create a buffer to write our archive to.
|
||||
fw, err := os.Create("double-evil.zip")
|
||||
if nil != err {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
// Create a new zip archive.
|
||||
w := zip.NewWriter(fw)
|
||||
|
||||
// Write the evil symlink
|
||||
h := &zip.FileHeader{
|
||||
Name: "bad/file.txt",
|
||||
Method: zip.Deflate,
|
||||
Modified: time.Now(),
|
||||
}
|
||||
h.SetMode(os.ModeSymlink)
|
||||
header, err := w.CreateHeader(h)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// The evil symlink points outside of the target directory
|
||||
_, err = header.Write([]byte("../../badfile.txt"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Write safe files to the archive.
|
||||
var files = []struct {
|
||||
Name, Body string
|
||||
}{
|
||||
{"goodfile.txt", "hello world"},
|
||||
{"morefile.txt", "hello world"},
|
||||
{"bad/file.txt", "Mwa-ha-ha"},
|
||||
}
|
||||
for _, file := range files {
|
||||
h := &zip.FileHeader{
|
||||
Name: file.Name,
|
||||
Method: zip.Deflate,
|
||||
Modified: time.Now(),
|
||||
}
|
||||
|
||||
header, err := w.CreateHeader(h)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = header.Write([]byte(file.Body))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// close the in-memory archive so that it writes trailing data
|
||||
if err = w.Close(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// close the on-disk archive so that it flushes all bytes
|
||||
if err = fw.Close(); err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
}
|
BIN
testdata/gnu-hardlinks.tar
vendored
Normal file
BIN
testdata/gnu-hardlinks.tar
vendored
Normal file
Binary file not shown.
BIN
testdata/sample.rar
vendored
Normal file
BIN
testdata/sample.rar
vendored
Normal file
Binary file not shown.
BIN
testdata/testarchives/evilarchives/double-evil.tar
vendored
Normal file
BIN
testdata/testarchives/evilarchives/double-evil.tar
vendored
Normal file
Binary file not shown.
BIN
testdata/testarchives/evilarchives/double-evil.zip
vendored
Normal file
BIN
testdata/testarchives/evilarchives/double-evil.zip
vendored
Normal file
Binary file not shown.
BIN
testdata/testarchives/evilarchives/evil.tar
vendored
Normal file
BIN
testdata/testarchives/evilarchives/evil.tar
vendored
Normal file
Binary file not shown.
BIN
testdata/testarchives/evilarchives/evil.tar.bz2
vendored
Normal file
BIN
testdata/testarchives/evilarchives/evil.tar.bz2
vendored
Normal file
Binary file not shown.
BIN
testdata/testarchives/evilarchives/evil.tar.gz
vendored
Normal file
BIN
testdata/testarchives/evilarchives/evil.tar.gz
vendored
Normal file
Binary file not shown.
BIN
testdata/testarchives/evilarchives/evil.zip
vendored
Normal file
BIN
testdata/testarchives/evilarchives/evil.zip
vendored
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue