kirm / sip.js

Session Initiation Protocol for node.js
MIT License
427 stars 171 forks source link

Crashes on malformed recognized header #136

Closed SlugFiller closed 4 years ago

SlugFiller commented 5 years ago

If a well-formed SIP message is received, but one of its recognized headers contains malformed content, e.g. CSeq: abcdefg then it will crash the program.

The cause is in this line: m.headers[name] = (parsers[name] || parseGenericHeader)({s:r[2], i:0}, m.headers[name]);

The problem is that any of the given parsers may crash on invalid input. And since this is called from the transport layer, this can bubble all the way up without encountering any app-specific code.

This could be fixed either with a try-catch, or by rewriting the parsers to handle invalid input more gracefully.

kirm commented 4 years ago

Fixed.