SpiderLabs/ModSecurity — pull request #10 by hideaki (2012-11-13 01:13:00+00:00)
Title: fix for issues in ssn_verify such as infinite loop.

This is fixes in ssn_verify, which verifies valid US social security number.
I figured that it's intention is the following.

- Reject if it does not include 9 numeric chars.
- Reject if the 9 digits are repetition of same number. ex. 111-11-1111
- Reject if the 9 digits are sequential numbers. ex. 123-45-6789
- Reject if one of the fields are all zero. ex. 235-00-4829
- Reject if the first 3 digits are 666 or larger than or equal to 740

The function ssn_verify had following issues, which I fixed in this patch.

- Infinite loop caused by mixing i (string index) and digits (digits index)
- false negative caused by mixing len-1 (string length - 1) and 8 (number of digits - 1)
ex. 123-45-6789 was considered valid before fixing this.
- cleaned up usage of variable names.
For example, variable "sequencial" was used for check
of not being repetition of same numbers.
- For the clarity of the code, I made sequential check logic similar to repetition check logic.
(check if the times adjacent digits are sequential/repetitive are 8 or not.)