Merge pull request #113 from projectdiscovery/bugfix-store-response

avoid fatal on store response error
This commit is contained in:
bauthard 2020-09-22 11:19:20 +05:30 committed by GitHub
commit 22cc61b657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}
}