keywords: encode xattr.* keywords with Vis

This allows for xattr keywords to include spaces and other such options
(which is perfectly valid according to the definition of Lsetxattr --
any character except '\x00' is fair game).

Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
Aleksa Sarai 2016-12-18 02:57:45 +11:00
parent 94d7041e8e
commit f9adee80f4
No known key found for this signature in database
GPG key ID: 9E18AA267DDB8DB4

View file

@ -62,7 +62,11 @@ var (
}
klist := []KeyVal{}
for k, v := range hdr.Xattrs {
klist = append(klist, KeyVal(fmt.Sprintf("xattr.%s=%s", k, base64.StdEncoding.EncodeToString([]byte(v)))))
encKey, err := Vis(k, DefaultVisFlags)
if err != nil {
return emptyKV, err
}
klist = append(klist, KeyVal(fmt.Sprintf("xattr.%s=%s", encKey, base64.StdEncoding.EncodeToString([]byte(v)))))
}
return KeyVal(strings.Join(KeyValToString(klist), " ")), nil
}
@ -80,7 +84,11 @@ var (
if err != nil {
return emptyKV, err
}
klist[i] = KeyVal(fmt.Sprintf("xattr.%s=%s", xlist[i], base64.StdEncoding.EncodeToString(data)))
encKey, err := Vis(xlist[i], DefaultVisFlags)
if err != nil {
return emptyKV, err
}
klist[i] = KeyVal(fmt.Sprintf("xattr.%s=%s", encKey, base64.StdEncoding.EncodeToString(data)))
}
return KeyVal(strings.Join(KeyValToString(klist), " ")), nil
}