Skip to content

Commit

Permalink
avoid fatal on store response error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mzack9999 committed Sep 21, 2020
1 parent d26783f commit f71cb97
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/httpx/httpx.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,17 @@ retry:
if port > 0 {
domainFile = fmt.Sprintf("%s.%d%s", domain, port, scanopts.RequestURI)
}
// On various OS the file max file name length is 255 - https://serverfault.com/questions/9546/filename-length-limits-on-linux
// Truncating length at 255
if len(domainFile) >= 255 {
// leaving last 4 bytes free to append ".txt"
domainFile = domainFile[:251]
}
domainFile = strings.Replace(domainFile, "/", "_", -1) + ".txt"
responsePath := path.Join(scanopts.StoreResponseDirectory, domainFile)
err := ioutil.WriteFile(responsePath, []byte(resp.Raw), 0644)
if err != nil {
gologger.Fatalf("Could not write response, at path '%s', to disc.", responsePath)
gologger.Warningf("Could not write response, at path '%s', to disc.", responsePath)
}
}

Expand Down

0 comments on commit f71cb97

Please sign in to comment.