Skip to content

Commit

Permalink
fix(kvstoreentry): avoid runtime panic for out of bound slice index (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist authored Jun 22, 2023
1 parent 92b0623 commit 7ca3822
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/commands/kvstoreentry/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ func (c *CreateCommand) ProcessDir(in io.Reader, out io.Writer) error {
filePath := filepath.Join(c.dirPath, file.Name())
dir, filename := filepath.Split(filePath)
index := strings.Index(dir, base)
// If the user runs from `--dir .` (current directory)
if index == -1 {
index = 0
}
filename = filepath.Join(dir[index:], filename)

if c.Globals.Verbose() {
Expand Down

0 comments on commit 7ca3822

Please sign in to comment.