X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/400e4596d20b4b57a6d7bd2dd280f027800a8da6..9f842eecf59f293fd800ece28be2730ff3a39487:/sdk/go/arvados/collection_fs.go diff --git a/sdk/go/arvados/collection_fs.go b/sdk/go/arvados/collection_fs.go index 429fabf7b5..d8ee2a2b1c 100644 --- a/sdk/go/arvados/collection_fs.go +++ b/sdk/go/arvados/collection_fs.go @@ -864,7 +864,7 @@ func (dn *dirnode) loadManifest(txt string) error { return fmt.Errorf("line %d: bad locator %q", lineno, token) } - toks := strings.Split(token, ":") + toks := strings.SplitN(token, ":", 3) if len(toks) != 3 { return fmt.Errorf("line %d: bad file segment %q", lineno, token) } @@ -1078,6 +1078,10 @@ func (dn *dirnode) Rename(oldname, newname string) error { if !ok { return os.ErrNotExist } + if locked[oldinode] { + // oldinode cannot become a descendant of itself. + return ErrInvalidArgument + } if existing, ok := newdn.inodes[newname]; ok { // overwriting an existing file or dir if dn, ok := existing.(*dirnode); ok { @@ -1345,9 +1349,9 @@ func (me *memSegment) ReadAt(p []byte, off int64) (n int, err error) { type storedSegment struct { kc keepClient locator string - size int - offset int - length int + size int // size of stored block (also encoded in locator) + offset int // position of segment within the stored block + length int // bytes in this segment (offset + length <= size) } func (se storedSegment) Len() int { @@ -1389,7 +1393,7 @@ func canonicalName(name string) string { return name } -var manifestEscapeSeq = regexp.MustCompile(`\\([0-9]{3}|\\)`) +var manifestEscapeSeq = regexp.MustCompile(`\\([0-7]{3}|\\)`) func manifestUnescapeFunc(seq string) string { if seq == `\\` { @@ -1407,7 +1411,7 @@ func manifestUnescape(s string) string { return manifestEscapeSeq.ReplaceAllStringFunc(s, manifestUnescapeFunc) } -var manifestEscapedChar = regexp.MustCompile(`[^\.\w/]`) +var manifestEscapedChar = regexp.MustCompile(`[\000-\040:\s\\]`) func manifestEscapeFunc(seq string) string { return fmt.Sprintf("\\%03o", byte(seq[0]))