[RFC] [PATCH] Let PLUGIN_RAW plugins alter message lengths
Marc van der Wal <[email protected]> Wed, 21 May 2014 18:17:10 +0200
| Newsgroups | gmane.network.siproxd |
|---|---|
| Message-ID | <20140521161710.GA27061@freyja> |
--yrj/dFKFPuw6o+aM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
I am currently developing a custom plugin for siproxd. In some cases,
it needs to modify the raw message buffer in order to work around
libosip2's limitations (for example, libosip2 doesn't handle RFC
3966-style URIs correctly, while the upstream proxy I am communicating
with uses those).
However, by doing so I have noticed that the subsequent modified message
gets truncated, even though my code recalculates ticket->raw_buffer_len
correctly.
The issue lies in the fact that the buffer lengths used in the
subsequent checks are no longer valid if these are modified during the
PLUGIN_RAW phase. Instead, the recalculated buffer lengths within the
ticket should be used.
My attached patch therefore modifies all these checks to use
ticket.raw_buffer and ticket.raw_buffer_len instead of buff and buflen.
This is the only way I know to make this case (and a somewhat ugly one,
I know, hence the [RFC] tag) work correctly.
This patch is designed for siproxd-0.8.0 but might also apply cleanly to
more recent source trees.
Regards,
Marc van der Wal
--yrj/dFKFPuw6o+aM
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="0.8.0-siproxd-perform_checks_on_ticket.patch"
--- src/siproxd.c~ 2014-05-14 22:43:31.348725368 +0200
+++ src/siproxd.c 2014-05-14 22:45:22.706674127 +0200
@@ -408,7 +408,7 @@
/*
* integrity checks
*/
- sts=security_check_raw(buff, buflen);
+ sts=security_check_raw(ticket.raw_buffer, ticket.raw_buffer_len);
if (sts != STS_SUCCESS) {
DEBUGC(DBCLASS_SIP,"security check (raw) failed");
continue; /* there are no resources to free */
@@ -417,7 +417,7 @@
/*
* Hacks to fix-up some broken headers
*/
- sts=sip_fixup_asterisk(buff, &buflen);
+ sts=sip_fixup_asterisk(ticket.raw_buffer, &ticket.raw_buffer_len);
/*
* init sip_msg
@@ -434,10 +434,10 @@
* Proxy Behavior - Request Validation - Reasonable Syntax
* (parse the received message)
*/
- sts=sip_message_parse(ticket.sipmsg, buff, buflen);
+ sts=sip_message_parse(ticket.sipmsg, ticket.raw_buffer, ticket.raw_buffer_len);
if (sts != 0) {
ERROR("sip_message_parse() failed... this is not good");
- DUMP_BUFFER(-1, buff, buflen);
+ DUMP_BUFFER(-1, ticket.raw_buffer, ticket.raw_buffer_len);
goto end_loop; /* skip and free resources */
}
@@ -447,7 +447,7 @@
sts=security_check_sip(&ticket);
if (sts != STS_SUCCESS) {
ERROR("security_check_sip() failed... this is not good");
- DUMP_BUFFER(-1, buff, buflen);
+ DUMP_BUFFER(-1, ticket.raw_buffer, ticket.raw_buffer_len);
goto end_loop; /* skip and free resources */
}
--yrj/dFKFPuw6o+aM
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
--yrj/dFKFPuw6o+aM
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Siproxd-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/siproxd-users
--yrj/dFKFPuw6o+aM--