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

Liviu Chircu liviu at opensips.org
Fri May 25 04:41:33 EDT 2018


  Branch: refs/heads/2.2
  Home:   https://github.com/OpenSIPS/opensips
  Commit: eed7a5019411b5061325488d6026ada77e45997b
      https://github.com/OpenSIPS/opensips/commit/eed7a5019411b5061325488d6026ada77e45997b
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2018-05-25 (Fri, 25 May 2018)

  Changed paths:
    M modules/path/path.c
    M modules/registrar/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)
(cherry picked from commit 6e0ec1f7bae4b5a5076fce445d28ba1cbf790feb)


  Commit: 34751fecf17a67da5626ea1cc8c58b345b350df9
      https://github.com/OpenSIPS/opensips/commit/34751fecf17a67da5626ea1cc8c58b345b350df9
  Author: Liviu Chircu <liviu at opensips.org>
  Date:   2018-05-25 (Fri, 25 May 2018)

  Changed paths:
    M modules/path/path.c
    M modules/registrar/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)
(cherry picked from commit 109f7dace65d8e0c87c9a025e8f434768fd52b5f)


Compare: https://github.com/OpenSIPS/opensips/compare/1df7195a14ec...34751fecf17a
      **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