cmd: close resp.Body to avoid memory leak

This commit is contained in:
Sol Fisher Romanoff
2023-09-06 10:59:20 +03:00
parent e2504eab48
commit 4d7c01bc76
6 changed files with 6 additions and 0 deletions
+1
View File
@@ -63,6 +63,7 @@ func Dirlist(size string, url string, timeout time.Duration, threads int, logdir
log.Errorf("Error downloading directory list: %s", err)
return
}
defer resp.Body.Close()
var directories []string
scanner := bufio.NewScanner(resp.Body)
scanner.Split(bufio.ScanLines)
+1
View File
@@ -51,6 +51,7 @@ func Dnslist(size string, url string, timeout time.Duration, threads int, logdir
log.Errorf("Error downloading DNS list: %s", err)
return
}
defer resp.Body.Close()
var dns []string
scanner := bufio.NewScanner(resp.Body)
scanner.Split(bufio.ScanLines)
+1
View File
@@ -48,6 +48,7 @@ func Dork(url string, timeout time.Duration, threads int, logdir string) {
log.Errorf("Error downloading dork list: %s", err)
return
}
defer resp.Body.Close()
var dorks []string
scanner := bufio.NewScanner(resp.Body)
scanner.Split(bufio.ScanLines)
+1
View File
@@ -47,6 +47,7 @@ func Git(url string, timeout time.Duration, threads int, logdir string) {
log.Errorf("Error downloading git list: %s", err)
return
}
defer resp.Body.Close()
var gitUrls []string
scanner := bufio.NewScanner(resp.Body)
scanner.Split(bufio.ScanLines)
+1
View File
@@ -44,6 +44,7 @@ func Ports(scope string, url string, timeout time.Duration, threads int, logdir
log.Errorf("Error downloading ports list: %s", err)
return
}
defer resp.Body.Close()
scanner := bufio.NewScanner(resp.Body)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
+1
View File
@@ -46,6 +46,7 @@ func Scan(url string, timeout time.Duration, threads int, logdir string) {
if err != nil {
log.Debugf("Error: %s", err)
}
defer resp.Body.Close()
if resp.StatusCode != 404 && resp.StatusCode != 301 && resp.StatusCode != 302 && resp.StatusCode != 307 {
scanlog.Infof("file [%s] found", statusstyle.Render("robots.txt"))