Skip to content

Commit

Permalink
Fix Issue696 -- Divide by 0 Error when setting rate to 0 manually (#700)
Browse files Browse the repository at this point in the history
* added check to RateThrottle.ChangeRate() in rate.go to prevent a divide by 0 error when the rate is set to 0. Ref: issue 696: #696

* added name to contributors.md and small change description to changelog.md as requested in PR doc

* Update CONTRIBUTORS.md

---------

Co-authored-by: Joona Hoikkala <5235109+joohoi@users.noreply.github.com>
  • Loading branch information
Ephex2 and joohoi committed Sep 13, 2023
1 parent 301968c commit 96fef62
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
- Changed
- Explicitly allow TLS1.0
- Fix markdown output file format
- Fixed divide by 0 error when setting rate limit to 0 manually.

- v2.0.0
- New
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTORS.md
Expand Up @@ -14,6 +14,7 @@
* [Daviey](https://github.com/Daviey)
* [delic](https://github.com/delic)
* [denandz](https://github.com/denandz)
* [Ephex2](https://github.com/Ephex2)
* [erbbysam](https://github.com/erbbysam)
* [eur0pa](https://github.com/eur0pa)
* [fabiobauer](https://github.com/fabiobauer)
Expand Down Expand Up @@ -47,4 +48,3 @@
* [SolomonSklash](https://github.com/SolomonSklash)
* [TomNomNom](https://github.com/tomnomnom)
* [xfgusta](https://github.com/xfgusta)

7 changes: 6 additions & 1 deletion pkg/ffuf/rate.go
Expand Up @@ -65,7 +65,12 @@ func (r *RateThrottle) CurrentRate() int64 {
}

func (r *RateThrottle) ChangeRate(rate int) {
ratemicros := 1000000 / rate
ratemicros := 0 // set default to 0, avoids integer divide by 0 error

if rate != 0 {
ratemicros = 1000000 / rate
}

r.RateLimiter.Stop()
r.RateLimiter = time.NewTicker(time.Microsecond * time.Duration(ratemicros))
r.Config.Rate = int64(rate)
Expand Down

0 comments on commit 96fef62

Please sign in to comment.