Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
bugfix in mergedirectories for go-fuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevgeny Pats committed Oct 5, 2019
1 parent 20fdc56 commit 6ab86ff
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
14 changes: 7 additions & 7 deletions client/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ func (c *FuzzitClient) RunFuzzer(job Job, jobId string, updateDB bool) error {
}
}

if _, err := os.Stat("corpus"); os.IsNotExist(err) {
if err := os.Mkdir("corpus", 0644); err != nil {
return err
}
if err := createDirIfNotExist("corpus"); err != nil {
return err
}

if jobId != "" {
Expand All @@ -137,9 +135,6 @@ func (c *FuzzitClient) RunFuzzer(job Job, jobId string, updateDB bool) error {
}

log.Println("downloading additional corpus")
if err := os.Mkdir("additional-corpus", 0644); err != nil {
return err
}
if err := c.downloadAndExtract(
"additional-corpus",
fmt.Sprintf("orgs/%s/targets/%s/jobs/%s/additional-corpus", c.Org, c.currentJob.TargetId, c.jobId)); err != nil {
Expand All @@ -149,6 +144,11 @@ func (c *FuzzitClient) RunFuzzer(job Job, jobId string, updateDB bool) error {
return err
}
}

if err := createDirIfNotExist("additional-corpus"); err != nil {
return err
}

}

var err error
Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

const FuzzitEndpoint = "https://app.fuzzit.dev"
const Version = "v2.4.71"
const Version = "v2.4.72"

type Target struct {
Name string `firestore:"target_name"`
Expand Down
18 changes: 15 additions & 3 deletions client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,25 @@ func mergeDirectories(dst string, src string) error {
}
if !info.IsDir() {
fileName := info.Name()
err = os.Rename(filepath.Join(src, fileName), filepath.Join(dst, fileName))
if err != nil {
return err
dstPath := filepath.Join(dst, fileName)
if _, err := os.Stat(path); os.IsNotExist(err) {
err = os.Rename(filepath.Join(src, fileName), dstPath)
if err != nil {
return err
}
}
}
return nil
})

return err
}

func createDirIfNotExist(path string) error {
if _, err := os.Stat(path); os.IsNotExist(err) {
if err := os.Mkdir(path, 0644); err != nil {
return err
}
}
return nil
}

0 comments on commit 6ab86ff

Please sign in to comment.