aboutsip / pkts

Pure java based pcap library capable of reading and writing to/from pcaps.
Other
198 stars 92 forks source link

Fixes 106 - Infinite loop for whitespace in param handling in URI #108

Closed jonbo372 closed 5 years ago

jonbo372 commented 5 years ago

According to specification, a name-addr is not allowed to have any white space between the host and the parameter list like so: <sip:alice@example.com; wrong=no_space_please>. However, this does occur in the "wild" and just "looking" at the address, it is clear that those parameters should belong to the URI. Therefore, those extra spaces should really be allowed so the fix is essentially relaxing the rules a bit.

Then, even if the old rules were more strict, we shouldn't end up in a loop. It is unclear exactly what the customer who reported the issue ran into but ultimately, due to the above poor parsing, we ended up with a ParametersSupport that had "bad values" it couldn't parse and got stuck in an endless loop.

So, there were several contributing issues (it seems).

  1. Poor parsing of the address-spec, which then exposed
  2. a bug in ParametersSupport that could cause an infinite loop

This fix addresses both. More robust (relaxed) parsing and fix in the ParametersSupport to detect and bail out if we are not making any progress.