Skip to content

fix for issues in ssn_verify such as infinite loop. #10

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

Merged
Merged
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
27 changes: 11 additions & 16 deletions apache2/re_operators.c
Original file line number Diff line number Diff line change
Expand Up @@ -3170,40 +3170,35 @@ static int ssn_verify(modsec_rec *msr, const char *ssnumber, int len) {
int area, serial, grp;
int sequencial = 0;
int repetitions = 0;
int progression = 0;
char *str_area;
char *str_grp;
char *str_serial;

for (i = 0; i < len; i++) {
if (apr_isdigit(ssnumber[i])) {
num[i] = convert_to_int(ssnumber[i]);
digits++;
if (digits < 9)
num[digits] = convert_to_int(ssnumber[i]);
digits++;
}
}

/* Not a valid number */
if (digits != 9)
goto invalid;

digits = 0;

for (i=0; i < len-1; i++) {
progression = (num[i] - (num[i+1]-1));
repetitions = (num[i] - num[i+1]);
for (i=0; i < 8; i++) {
if (num[i] == (num[i+1]-1))
sequencial++;

if (repetitions != 0 )
sequencial = 1;

if (progression == 0)
digits++;
if (num[i] == num[i+1])
repetitions++;
}

/* We are blocking when all numbers were repeated */
if (sequencial == 0)
/* We are blocking when all numbers were sequencial or repeated */
if (sequencial == 8)
goto invalid;

if (digits == 8)
if (repetitions == 8)
goto invalid;

str_area = apr_psprintf(msr->mp,"%d%d%d",num[0],num[1],num[2]);
Expand Down