Fix Issue696 -- Divide by 0 Error when setting rate to 0 manually (#700)

* 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: https://github.com/ffuf/ffuf/issues/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>
This commit is contained in:
Ephex2 2023-09-13 04:31:40 -04:00 committed by GitHub
parent 301968cb1c
commit 96fef6213d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

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

View file

@ -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)
@ -47,4 +48,3 @@
* [SolomonSklash](https://github.com/SolomonSklash)
* [TomNomNom](https://github.com/tomnomnom)
* [xfgusta](https://github.com/xfgusta)

View file

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