mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 00:04:53 +00:00
res_pjsip_notify: Only allow a single Event header to be added to a NOTIFY
ASTERISK-27775 #close Reported by: AvayaXAsterisk Change-Id: Iad158e908e34675ad98f74d09c5e73024e50c257
This commit is contained in:
@@ -511,6 +511,16 @@ static int not_allowed(const char *name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \internal
|
||||||
|
* \brief Check if the given header can be added to a message more than once.
|
||||||
|
*/
|
||||||
|
static int multiple_headers_allowed(const char *name)
|
||||||
|
{
|
||||||
|
/* This can be extended to include additional headers */
|
||||||
|
return strcasecmp("Event", name);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \internal
|
* \internal
|
||||||
* \brief If a content type was specified add it and the content body to the
|
* \brief If a content type was specified add it and the content body to the
|
||||||
@@ -564,6 +574,18 @@ static void build_notify(pjsip_tx_data *tdata, const char *name, const char *val
|
|||||||
}
|
}
|
||||||
ast_str_append(content, 0, "%s", value);
|
ast_str_append(content, 0, "%s", value);
|
||||||
} else {
|
} else {
|
||||||
|
/* See if there is an existing one */
|
||||||
|
if (!multiple_headers_allowed(name)) {
|
||||||
|
pj_str_t hdr_name;
|
||||||
|
pj_cstr(&hdr_name, name);
|
||||||
|
|
||||||
|
if (pjsip_msg_find_hdr_by_name(tdata->msg, &hdr_name, NULL)) {
|
||||||
|
ast_log(LOG_ERROR, "Only one '%s' header can be added to a NOTIFY, "
|
||||||
|
"ignoring \"%s: %s\"\n", name, name, value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ast_sip_add_header(tdata, name, value);
|
ast_sip_add_header(tdata, name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user