mirror of
https://github.com/lammertb/libhttp.git
synced 2025-12-22 04:02:04 +03:00
exception if invalid throttle parameter is used
If '*' is used as `throttle` parameter, there is a segfault at the first request (see #350). This is a quick fix to avoid the segfault exception. Note that in general civetweb.c does not check parameters in advance, in order to keep the code simple. Other invalid parameters may still cause exceptions. It is the responsibility of the caller to pass valid parameters to mg_start.
This commit is contained in:
@@ -9680,9 +9680,9 @@ set_throttle(const char *spec, uint32_t remote_ip, const char *uri)
|
|||||||
|
|
||||||
while ((spec = next_option(spec, &vec, &val)) != NULL) {
|
while ((spec = next_option(spec, &vec, &val)) != NULL) {
|
||||||
mult = ',';
|
mult = ',';
|
||||||
if (sscanf(val.ptr, "%lf%c", &v, &mult) < 1 || v < 0
|
if ((val.ptr == NULL) || (sscanf(val.ptr, "%lf%c", &v, &mult) < 1)
|
||||||
|| (lowercase(&mult) != 'k' && lowercase(&mult) != 'm'
|
|| (v < 0) || ((lowercase(&mult) != 'k')
|
||||||
&& mult != ',')) {
|
&& (lowercase(&mult) != 'm') && (mult != ','))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
v *= (lowercase(&mult) == 'k')
|
v *= (lowercase(&mult) == 'k')
|
||||||
|
|||||||
Reference in New Issue
Block a user