Skip to content

Few types change can be safely #1624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: v2/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apache2/apache2_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static void copy_rules_phase(apr_pool_t *mp,
switch(exceptions[j]->type) {
case RULE_EXCEPTION_REMOVE_ID :
if ((rule->actionset != NULL)&&(rule->actionset->id != NULL)) {
int ruleid = atoi(rule->actionset->id);
long ruleid = strtol(rule->actionset->id, 0, 10);
if (rule_id_in_range(ruleid, exceptions[j]->param)) copy--;
}
break;
Expand Down Expand Up @@ -2471,7 +2471,8 @@ static const char *cmd_rule_remove_by_msg(cmd_parms *cmd, void *_dcfg,
static const char *cmd_rule_update_action_by_id(cmd_parms *cmd, void *_dcfg,
const char *p1, const char *p2)
{
int offset = 0, rule_id = atoi(p1);
int offset = 0;
long rule_id = strtol(p1, 0, 10);
char *opt = strchr(p1,':');
char *savedptr = NULL;
char *param = apr_pstrdup(cmd->pool, p1);
Expand Down
14 changes: 7 additions & 7 deletions apache2/mod_security2.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int perform_interception(modsec_rec *msr) {
msre_actionset *actionset = NULL;
const char *message = NULL;
const char *phase_text = "";
unsigned int pause = 0;
unsigned long pause = 0;
int status = DECLINED;
int log_level = 1;

Expand Down Expand Up @@ -188,20 +188,20 @@ int perform_interception(modsec_rec *msr) {
var->value_len = strlen(actionset->intercept_pause);
expand_macros(msr, var, NULL, msr->mp);

pause = atoi(var->value);
if ((pause == LONG_MAX)||(pause == LONG_MIN)||(pause <= 0))
pause = strtoul(var->value, 0, 10);
if ((pause == ULONG_MAX)||(pause == LONG_MIN)||(pause <= 0))
pause = 0;

msr_log(msr, (log_level > 3 ? log_level : log_level + 1), "Pausing transaction for "
"%d msec.", pause);
"%lu msec.", pause);
/* apr_sleep accepts microseconds */
apr_sleep((apr_interval_time_t)(pause * 1000));
} else {
pause = atoi(actionset->intercept_pause);
if ((pause == LONG_MAX)||(pause == LONG_MIN)||(pause <= 0))
pause = strtoul(actionset->intercept_pause, 0, 10);
if ((pause == ULONG_MAX)||(pause == LONG_MIN)||(pause <= 0))
pause = 0;
msr_log(msr, (log_level > 3 ? log_level : log_level + 1), "Pausing transaction for "
"%d msec.", pause);
"%lu msec.", pause);
/* apr_sleep accepts microseconds */
apr_sleep((apr_interval_time_t)(pause * 1000));
}
Expand Down
4 changes: 2 additions & 2 deletions apache2/re.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ int msre_ruleset_rule_matches_exception(msre_rule *rule, rule_exception *re) {
switch(re->type) {
case RULE_EXCEPTION_REMOVE_ID :
if ((rule->actionset != NULL)&&(rule->actionset->id != NULL)) {
int ruleid = atoi(rule->actionset->id);
long ruleid = atoi(rule->actionset->id);

if (rule_id_in_range(ruleid, re->param)) {
match = 1;
Expand Down Expand Up @@ -3385,7 +3385,7 @@ static apr_status_t msre_rule_process(msre_rule *rule, modsec_rec *msr) {
/**
* Checks whether the given rule ID is in the given range.
*/
int rule_id_in_range(int ruleid, const char *range) {
int rule_id_in_range(long ruleid, const char *range) {
char *p = NULL, *saveptr = NULL;
char *data = NULL;

Expand Down
2 changes: 1 addition & 1 deletion apache2/re.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ msre_var DSOLOCAL *msre_create_var_ex(apr_pool_t *pool, msre_engine *engine, con
int DSOLOCAL msre_parse_generic(apr_pool_t *pool, const char *text, apr_table_t *vartable,
char **error_msg);

int DSOLOCAL rule_id_in_range(int ruleid, const char *range);
int DSOLOCAL rule_id_in_range(long ruleid, const char *range);

msre_var DSOLOCAL *generate_single_var(modsec_rec *msr, msre_var *var, apr_array_header_t *tfn_arr,
msre_rule *rule, apr_pool_t *mptmp);
Expand Down
4 changes: 2 additions & 2 deletions apache2/re_actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,14 @@ static apr_status_t msre_action_id_init(msre_engine *engine, apr_pool_t *mp, msr
}

static char *msre_action_id_validate(msre_engine *engine, apr_pool_t *mp, msre_action *action) {
int id;
long id;

if(action != NULL && action->param != NULL) {
for(id=0;id<strlen(action->param);id++) {
if(!apr_isdigit(action->param[id]))
return apr_psprintf(mp, "ModSecurity: Invalid value for action ID: %s", action->param);
}
id = atoi(action->param);
id = strtol(action->param, 0, 10);
if ((id == LONG_MAX)||(id == LONG_MIN)||(id <= 0)) {
return apr_psprintf(mp, "ModSecurity: Invalid value for action ID: %s", action->param);
}
Expand Down
Loading