Infinite loop caused in mod9710 by some invalid IBANs
dantman opened this issue · 1 comments
dantman commented
Describe the bug
Trying to validate some invalid IBAN strings will trigger an infinite loop/DOS instead of returning an error.
To Reproduce
const { validateIBAN } = require('ibantools');
validateIBAN('SI94BARC102');
Expected behavior
Presumably this should return some sort of error instead of mod9710 looping infinitely.
Additional context
The infinite loop happens in mod9710.
- Given the invalid IBAN
SI94BARC102
mod9710 gets the inputBARC102
- It takes
BARC10
out as the first part validationString
becomesNaN2
- On next iteration
validationString
becomes"NaN"
- And it continues iterating infinitely with
validationString
as"NaN"
which never has a length less than 2.