Skip to content

Commit

Permalink
Solving bug where the ContentLength might come as -1 (unknown) random…
Browse files Browse the repository at this point in the history
…ly and cause a panic.
  • Loading branch information
Macmod committed Mar 17, 2023
1 parent 319ac6b commit 2e40dcc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ For instance, if you just want to find publicly exposed containers using large l

If, on the other hand, you want to test a small list of very popular container names against a large set of storage accounts, you might want to try `-invertsearch=true` with `-maxpages=0`, in order to see the public accounts for each container name instead of the container names for each storage account.

You may also want to try changing `goroutines`, `-timeout` and `-maxidleconns`, `-maxidleconnsperhost` and `-maxconnsperhost` and `-skipssl` in order to best use your bandwidth and find results faster.
You may also want to try changing `-goroutines`, `-timeout` and `-maxidleconns`, `-maxidleconnsperhost` and `-maxconnsperhost` and `-skipssl` in order to best use your bandwidth and find results faster.

Experiment with the flags to find what works best for you ;-)

## Example

TODO: Put example here


# Contributing
Contributions are welcome by [opening an issue](https://github.com/Macmod/goblob/issues/new) or by [submitting a pull request](https://github.com/Macmod/goblob/pulls).
Expand Down
9 changes: 8 additions & 1 deletion core/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ func (cs *ContainerScanner) ScanContainer(account string, containerName string,
statusCode := resp.StatusCode
defer resp.Body.Close()

resBuf := make([]byte, resp.ContentLength)
var preallocBufferSize int64
if resp.ContentLength >= 0 {
preallocBufferSize = resp.ContentLength
} else {
preallocBufferSize = 128
}

var resBuf = make([]byte, preallocBufferSize)
resBuf, err = io.ReadAll(resp.Body)

if err != nil {
Expand Down

0 comments on commit 2e40dcc

Please sign in to comment.