From 28f0b90c25a449b4918d2bffaa2d04daea13c192 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Mon, 1 May 2017 20:09:17 +0200 Subject: [PATCH] zfs: check for forbidden dataset path characters --- zfs/zfs.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zfs/zfs.go b/zfs/zfs.go index 1d38643..09a34bb 100644 --- a/zfs/zfs.go +++ b/zfs/zfs.go @@ -45,7 +45,10 @@ func NewDatasetPath(s string) (p DatasetPath, err error) { if s == "" { return EmptyDatasetPath, nil // the empty dataset path } - // TODO validation + const FORBIDDEN = "@#|\t " + if strings.ContainsAny(s, FORBIDDEN) { // TODO space may be a bit too restrictive... + return nil, errors.New(fmt.Sprintf("path '%s' contains forbidden characters (any of '%s')", s, FORBIDDEN)) + } return toDatasetPath(s), nil }