1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2025-07-03 14:28:28 +00:00

keywords: safely encode symlink keywords

symlink(2) is a very dumb syscall, and allows you to put any damn value
you please inside a symlink. In addition, spaces are valid path
characters which causes issues with keyword parsing. So use Vis() and
Unvis() to safely store an encoded version of the path.

This also adds a cli test for this behaviour.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
Aleksa Sarai 2016-11-12 01:48:17 +11:00
parent 30ae0132eb
commit 704d91fc7c
No known key found for this signature in database
GPG key ID: 9E18AA267DDB8DB4
3 changed files with 39 additions and 3 deletions

6
tar.go
View file

@ -129,7 +129,11 @@ func (ts *tarStream) readHeaders() {
log.Println(err)
break
}
linkname := KeyVal(kv).Value()
linkname, err := Unvis(KeyVal(kv).Value())
if err != nil {
log.Println(err)
break
}
if _, ok := ts.hardlinks[linkname]; !ok {
ts.hardlinks[linkname] = []string{hdr.Name}
} else {