Skip to content

tool_getparam: Limit --rate to be smaller than number of ms#12116

Closed
sohomdatta1 wants to merge 1 commit into
curl:masterfrom
sohomdatta1:limit-rate-to-sensible-values
Closed

tool_getparam: Limit --rate to be smaller than number of ms#12116
sohomdatta1 wants to merge 1 commit into
curl:masterfrom
sohomdatta1:limit-rate-to-sensible-values

Conversation

@sohomdatta1

@sohomdatta1 sohomdatta1 commented Oct 13, 2023

Copy link
Copy Markdown
Contributor

Currently, curl allows users to specify absurd request rates that might be higher than the number of milliseconds in the unit (ex: curl --rate 3600050/h http://localhost:8080 does not error out despite there being only 3600000ms in a hour).

This PR adds a conditional check before the millisecond calculation making sure that the number is not higher than the numerator (the unit) If the number is higher, curl errors out with PARAM_NUMBER_TOO_LARGE

Currently, curl allows users to specify absurd request rates that
might be higher than the number of milliseconds in the unit
(ex: curl --rate 3600050/h http://localhost:8080 does not error out
despite there being only 3600000ms in a hour).

This PR adds a conditional check before the millisecond calculation
making sure that the number is not higher than the numerator (the unit)
If the number is higher, curl errors out with PARAM_NUMBER_TOO_LARGE
@sohomdatta1

sohomdatta1 commented Oct 13, 2023

Copy link
Copy Markdown
Contributor Author

In the current tool, the result of the division is zero for numbers higher than the number of ms in the unit, so it doesn't really make sense to keep that case around

@bagder bagder closed this in 8993efc Oct 14, 2023
@bagder

bagder commented Oct 14, 2023

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants