mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Fixed potential DIV0 when a collection var was fetched in the same second as creation
This commit is contained in:
parent
4e02be6219
commit
4370819f7b
3
CHANGES
3
CHANGES
@ -2,6 +2,9 @@
|
||||
01 Mar 2007 - 2.1.1-dev1
|
||||
------------------------
|
||||
|
||||
* Fixed error when a collection var was fetched in the same second as creation
|
||||
by setting the rate to zero.
|
||||
|
||||
* Fixed ASCIIZ (NUL) parsing for application/x-www-form-urlencoded forms
|
||||
|
||||
* Fixed the faulty REQUEST_FILENAME variable, which used to change
|
||||
|
@ -152,6 +152,7 @@ apr_table_t *collection_retrieve(modsec_rec *msr, const char *col_name,
|
||||
if (var == NULL) {
|
||||
/* Error. */
|
||||
} else {
|
||||
int td;
|
||||
counter = atoi(var->value);
|
||||
var = (msc_string *)apr_table_get(col, "UPDATE_RATE");
|
||||
if (var == NULL) {
|
||||
@ -160,8 +161,16 @@ apr_table_t *collection_retrieve(modsec_rec *msr, const char *col_name,
|
||||
var->name_len = strlen(var->name);
|
||||
apr_table_setn(col, var->name, (void *)var);
|
||||
}
|
||||
var->value = apr_psprintf(msr->mp, "%i",
|
||||
(int)((60 * counter)/(apr_time_sec(apr_time_now()) - create_time)));
|
||||
|
||||
/* NOTE: No rate if there has been no time elapsed */
|
||||
td = (apr_time_sec(apr_time_now()) - create_time);
|
||||
if (td == 0) {
|
||||
var->value = apr_psprintf(msr->mp, "%i", 0);
|
||||
}
|
||||
else {
|
||||
var->value = apr_psprintf(msr->mp, "%i",
|
||||
(int)((60 * counter)/td));
|
||||
}
|
||||
var->value_len = strlen(var->value);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user