From 22552265cefc80b400ff64156155f53a5d5751e6 Mon Sep 17 00:00:00 2001 From: Richard Lehane Date: Wed, 22 Apr 2015 14:27:21 +1000 Subject: [PATCH] fix bad dir structure err --- directory.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/directory.go b/directory.go index 0479bd1..576015c 100644 --- a/directory.go +++ b/directory.go @@ -233,10 +233,10 @@ func fixName(f *File) { func (r *Reader) traverse() error { r.indexes = make([]int, len(r.File)) var idx int - var recurse func(i int, path []string) + var recurse func(int, []string) var err error recurse = func(i int, path []string) { - if i < 0 || i >= len(r.File) || idx >= len(r.indexes) { + if i < 0 || i >= len(r.File) { err = ErrBadDir return } @@ -244,6 +244,10 @@ func (r *Reader) traverse() error { if file.leftSibID != noStream { recurse(int(file.leftSibID), path) } + if idx >= len(r.indexes) { + err = ErrBadDir + return + } r.indexes[idx] = i file.Path = path idx++