In strict mode messages with unknown elements are now rejected.
FossilOrigin-Name: b94b0107e8abfbe9074e34243918018afe0df89e44042a48ed0b100220504850
This commit is contained in:
@ -261,6 +261,8 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
/* Create an avltree to catch the found mandatory elements */
|
||||
conn->mand = stravltree_create();
|
||||
|
||||
int unrecognized=0;
|
||||
|
||||
/* iterate through message elements */
|
||||
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
||||
|
||||
@ -274,6 +276,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
af = cw_actionlist_in_get(conn->actions->in, &as);
|
||||
|
||||
if (!af) {
|
||||
unrecognized++;
|
||||
cw_dbg(DBG_ELEM_ERR,
|
||||
"Element %d (%s) not allowed in msg of type %d (%s), ignoring.",
|
||||
as.elem_id, cw_strelemp(conn->actions, as.elem_id),
|
||||
@ -304,6 +307,14 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
result_code = afm->end(conn, afm, rawmsg, len, from);
|
||||
}
|
||||
|
||||
if (unrecognized){
|
||||
cw_dbg(DBG_RFC,"Message has %d unrecognized message elements.",unrecognized);
|
||||
if (!result_code) {
|
||||
result_code = CW_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* if we've got a request message, we always have to send a response message */
|
||||
if (as.msg_id & 1) {
|
||||
if (result_code > 0) {
|
||||
|
Reference in New Issue
Block a user