retailnext/node-radius

Regex bug in parsing vendor id from vendors whose names begin with one or more digits.

chrisdew opened this issue · 2 comments

The regex at https://github.com/retailnext/node-radius/blob/master/lib/radius.js#L176 has a bug.

match = line.match(/^\s*(?:VENDOR)?ATTR(?:IBUTE)?\s+(\d+)?\s*(\S+)\s+(\d+)\s+(\S+)\s*(.+)?/);

Any vendor name which begins with a digit is processed as if its vendor id were the leading digits in its name.

VENDOR      3GPP                10415

E,g, the above is processed as a vendor id of 3, not 10415.

I was not able to reproduce the particular problem you described (that regex you specified is not the one used to parse vendor lines), but the problem you identified in the regex causes a similar problem where it misparses attribute names that start with numbers. I pushed a fix in 3b9cff8 where it's more explicit about the two VENDORATTR/ATTRIBUTE cases. Let me know if that resolves your issue.

Thanks, I'll have another look at this when I'm back on this project in a few weeks.