[OpenSIPS-Devel] [OpenSIPS/opensips] 0e6044: path: Add escaping logic for add_path_received()

Liviu Chircu liviu at opensips.org
Thu May 24 12:05:23 EDT 2018


  Branch: refs/heads/2.4
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 0e60448cb59b1bb4b6365da11fd187ad729bf52d
      https://github.com/OpenSIPS/opensips/commit/0e60448cb59b1bb4b6365da11fd187ad729bf52d
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M lib/path.c
    M lib/path.h
    M lib/reg/path.c
    M modules/path/path.c

  Log Message:
  -----------
  path: Add escaping logic for add_path_received()

Simply dumping a SIP URI as a ";received=" Path header field parameter
value is problematic and leads to two kinds of issues:

a. invalid SIP URIs, where the ";transport=" is specified twice:

Path: <sip:127.0.0.1:5061;transport=tcp;lr; ...
       ... received=sip:127.0.0.1:51959;transport=tcp>

b. in double Path scenarios (e.g. when switching protocols from, say,
TCP -> UDP), since the ";received=" is inserted as the
inbound Path header field value, this can lead to a strange
"protocol conversion" effect:

Path: <sip:127.0.0.1:5061;r2=on;lr ...
       ... ;received=sip:127.0.0.1:42917;transport=tcp>
Path: <sip:127.0.0.1:5061;transport=tcp;r2=on;lr>

^ notice how the inbound Path intended to advertise an UDP URI, but the
add_path_received() managed to "convert" it into a TCP URI because of
its inability to escape its token. nathelper is an easy first victim of
this conversion, as it will attempt to send pings using the incorrect
transport after reading the topmost Path (Route) header.

This patch adds escaping/unescaping logic for the ";received=" feature
of add_path_received() along with any code that makes use of this
feature. Example resulting URI for the above example:

Path: <sip:127.0.0.1:5061;r2=on;lr ...
       ... ;received=sip:127.0.0.1:42917%3dtransport%3btcp>

(cherry picked from commit b3bf15646affe981d4b266381d59f210e6e882fd)


  Commit: 045eea09bfb294f5a615d508bd3fc70317389563
      https://github.com/OpenSIPS/opensips/commit/045eea09bfb294f5a615d508bd3fc70317389563
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M lib/path.c
    M lib/reg/path.c

  Log Message:
  -----------
  path: Fix "use_path_received" in double-Path scenarios

Due to the fact that run_rr_callbacks() returns the 2nd Route (Path)
header field value when previously having done protocol switching (thus
having inserted two Path headers), the "use_path_received" feature of
the path module would not work -- it wouldn't set the $du at all.

The reason for this is that add_path_received() appends its ";received="
to inside Path #1 (the outbound path of the registration / the inbound
path of future requests) when doing double-Path recording.

This patch simply moves the ";received=" append operation performed by
add_path_received() into Path #2 (inbound path of registration /
outbound path of future requests), and adapts other code that needs it
(e.g. save("location", "p1v")) to properly be able to fetch it.

Reported by @futsystems

Fixes #1358

(cherry picked from commit 71c7d75f66c8f0dc4ce411fd97d2dc867b39ce8d)


  Commit: 0d75d93ed7f5a5e8ba079e79eb437ecd5f99487c
      https://github.com/OpenSIPS/opensips/commit/0d75d93ed7f5a5e8ba079e79eb437ecd5f99487c
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2018-05-24 (Thu, 24 May 2018)

  Changed paths:
    M lib/reg/path.c

  Log Message:
  -----------
  path: Fix leak-on-error

(cherry picked from commit 7911d636171f251b18a7d735d8baa9e15474b696)


Compare: https://github.com/OpenSIPS/opensips/compare/9a46432a05e3...0d75d93ed7f5
      **NOTE:** This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.


More information about the Devel mailing list