[chore]: Bump codeberg.org/gruf/go-store/v2 from 2.0.9 to 2.0.10 (#1160)

Bumps codeberg.org/gruf/go-store/v2 from 2.0.9 to 2.0.10.

---
updated-dependencies:
- dependency-name: codeberg.org/gruf/go-store/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
dependabot[bot]
2022-11-28 09:01:53 +00:00
committed by GitHub
parent 0c1b1b01f8
commit fe39d50e09
10 changed files with 362 additions and 18 deletions

View File

@@ -676,10 +676,6 @@ func (st *BlockStorage) nodePathForKey(key string) (string, error) {
pb := util.GetPathBuilder()
defer util.PutPathBuilder(pb)
// Append the nodepath to key
pb.AppendString(st.nodePath)
pb.AppendString(key)
// Return joined + cleaned node-path
return pb.Join(st.nodePath, key), nil
}

View File

@@ -394,16 +394,16 @@ func (st *DiskStorage) filepath(key string) (string, error) {
pb := util.GetPathBuilder()
defer util.PutPathBuilder(pb)
// Generated joined root path
pb.AppendString(st.path)
pb.AppendString(key)
// Generate key path
pb.Append(st.path)
pb.Append(key)
// Check for dir traversal outside of root
if isDirTraversal(st.path, pb.StringPtr()) {
if isDirTraversal(st.path, pb.String()) {
return "", ErrInvalidKey
}
return pb.String(), nil
return string(pb.B), nil
}
// isDirTraversal will check if rootPlusPath is a dir traversal outside of root,

View File

@@ -5,7 +5,7 @@ import (
"os"
"syscall"
"codeberg.org/gruf/go-fastpath"
"codeberg.org/gruf/go-fastpath/v2"
"codeberg.org/gruf/go-store/v2/util"
)

View File

@@ -1,16 +1,22 @@
package util
import (
"codeberg.org/gruf/go-fastpath"
"codeberg.org/gruf/go-pools"
"sync"
"codeberg.org/gruf/go-fastpath/v2"
)
// pathBuilderPool is the global fastpath.Builder pool.
var pathBuilderPool = pools.NewPathBuilderPool(512)
var pathBuilderPool = sync.Pool{
New: func() any {
return &fastpath.Builder{B: make([]byte, 0, 512)}
},
}
// GetPathBuilder fetches a fastpath.Builder object from the pool.
func GetPathBuilder() *fastpath.Builder {
return pathBuilderPool.Get()
pb, _ := pathBuilderPool.Get().(*fastpath.Builder)
return pb
}
// PutPathBuilder places supplied fastpath.Builder back in the pool.