aboutsip / pkts

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

SIP URI parser does not support IPv6 address #129

Closed teerapap closed 3 years ago

teerapap commented 3 years ago

SipParser throws an exception when parsing SIP Contact header with IPv6 address in the SIP URI.

The header Contact: <sip:user1@[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:34808;transport=TCP;ob>;expires=891

This exception is thrown

io.pkts.packet.sip.SipParseException: The SIP URI does not specify a valid host. Error encountered after 10 characters.
        at io.pkts.packet.sip.address.SipURI.frame(SipURI.java:242)
        at io.pkts.packet.sip.address.URI.frame(URI.java:74)
        at io.pkts.packet.sip.address.Address.frame(Address.java:152)
        at io.pkts.packet.sip.header.AddressParametersHeader.frame(AddressParametersHeader.java:43)
        at io.pkts.packet.sip.header.ContactHeader.frame(ContactHeader.java:60)
        at io.pkts.packet.sip.impl.SipParser.lambda$static$2(SipParser.java:206)
        at io.pkts.packet.sip.header.impl.SipHeaderImpl.ensure(SipHeaderImpl.java:75)
        at io.pkts.packet.sip.impl.SipParser.frame(SipParser.java:2185)
        ... 14 more
Caused by: io.pkts.packet.sip.SipParseException: The SIP URI does not specify a valid host. Error encountered after 6 characters.
        at io.pkts.packet.sip.impl.SipUserHostInfo$Parser.parse(SipUserHostInfo.java:184)
        at io.pkts.packet.sip.impl.SipUserHostInfo$Parser.access$100(SipUserHostInfo.java:89)
        at io.pkts.packet.sip.impl.SipUserHostInfo.frame(SipUserHostInfo.java:44)
        at io.pkts.packet.sip.impl.SipParser.consumeUserInfoHostPort(SipParser.java:1199)
        at io.pkts.packet.sip.address.SipURI.frame(SipURI.java:238)
        ... 24 more
teerapap commented 3 years ago

Fixed in #130