plugin_stripheaders: deal with mode header field

This commit is contained in:
Thomas Ries 2020-12-27 18:02:32 +01:00
parent 9d4c1ef172
commit 9e05d8cba5
3 changed files with 33 additions and 2 deletions

View File

@ -1,8 +1,10 @@
0.8.4dev
========
27-Dec-2020: - plugin_stripheaders: deal with mode header field
17-Sep-2020: - fix: buffer overflow in process_aclist if a
wrong syntax in config file was used for ACLs.
- Improved string handling on some more places.
0.8.3
=====
25-Aug-2020: - Released 0.8.3

View File

@ -448,16 +448,21 @@ plugin_regex_replace = \1:001
#
# unconditionally strip the specified SIP header from the packet.
# May be used to workaround IP fragmentation by removing "unimportant"
# SIP headers - this is clearly a ugly hack but sometimes saves on
# SIP headers - this is clearly a ugly hack but sometimes saves one
# from headache.
# Format is <header>[:<value>], the :<value> part is optional - if not
# present the full header will be removed.
# NOTE: not all headers are surrently supported due to how libosip
# does store them internally.
#
# remove entire header (all values attached to this header)
plugin_stripheader_remove = Allow
plugin_stripheader_remove = User-Agent
# remove only a particular value from a header (no spaces allowed)
plugin_stripheader_remove = Supported:100rel
# remove all Record-Route headers (only full removal is supported)
plugin_stripheader_remove = Record-Route
######################################################################
# Plugin_codecfilter

View File

@ -112,6 +112,12 @@ int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){
header_remove = strdup(plugin_cfg.header_remove.string[i]);
}
/*
* some headers are stored in their own struncture in the SIP message structure
* -> special cases
* and other headers are stored in a generic header structure
* -> generic headers
*/
/* special case Allow header */
if (strcasecmp(header_remove, "allow") == 0) {
@ -121,7 +127,7 @@ int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){
pos, &allow)) != -1) {
if (--dlc <= 0) { ERROR("deadlock counter has triggered. Likely a bug in code."); return STS_FAILURE;}
if (header_remove_args == NULL) {
/* remova all values for header */
/* remove all values for header */
DEBUGC(DBCLASS_PLUGIN, "%s: removing Allow header pos=%i, val=%s", name,
pos, allow->value);
osip_list_remove(&ticket->sipmsg->allows, pos);
@ -141,6 +147,24 @@ int PLUGIN_PROCESS(int stage, sip_ticket_t *ticket){
}
}
/* special case: Record-Route headers */
} else if (strcasecmp(header_remove, "record-route") == 0) {
osip_record_route_t *rroute=NULL;
pos=0;
while ((pos = osip_message_get_record_route(ticket->sipmsg,
pos, &rroute)) != -1) {
if (--dlc <= 0) { ERROR("deadlock counter has triggered. Likely a bug in code."); return STS_FAILURE;}
/* remove all values for header */
char *tmpstr=NULL;
osip_record_route_to_str(rroute, &tmpstr);
DEBUGC(DBCLASS_PLUGIN, "%s: removing Record-Route header pos=%i, val=%s", name,
pos, tmpstr);
osip_free(tmpstr);
osip_list_remove(&ticket->sipmsg->record_routes, pos);
osip_record_route_free(rroute);
rroute=NULL;
}
/* generic headers */
} else {
osip_header_t *h=NULL;