# HG changeset patch # User Thomas Klausner # Date 1603792204 -3600 # Node ID 2dbc816d48f44e445f63d8803ec5e2b56e8bd122 # Parent 5e29c00d6576de10e578ff25537985c6815beed5 Fail when a peer with empty Origin-Realm tries to connect. Empty Origin-Realms cause problems in the routing code later. Reduce warnings when reporting an empty Failed-AVP; both avp_source and avp_rawdata are NULL in this case. diff -r 5e29c00d6576 -r 2dbc816d48f4 libfdcore/p_ce.c --- a/libfdcore/p_ce.c Tue Oct 06 21:36:41 2020 +0800 +++ b/libfdcore/p_ce.c Tue Oct 27 10:50:04 2020 +0100 @@ -336,6 +336,14 @@ return EINVAL; } + /* Origin-Realm is empty */ + if (hdr->avp_value->os.len == 0) { + error->pei_errcode = "DIAMETER_INVALID_AVP_VALUE"; + error->pei_message = "Your Origin-Realm is empty."; + error->pei_avp = avp; + return EINVAL; + } + /* Save the value */ CHECK_MALLOC( peer->p_hdr.info.runtime.pir_realm = os0dup( hdr->avp_value->os.data, hdr->avp_value->os.len ) ); peer->p_hdr.info.runtime.pir_realmlen = hdr->avp_value->os.len; diff -r 5e29c00d6576 -r 2dbc816d48f4 libfdproto/messages.c --- a/libfdproto/messages.c Tue Oct 06 21:36:41 2020 +0800 +++ b/libfdproto/messages.c Tue Oct 27 10:50:04 2020 +0100 @@ -1776,13 +1776,13 @@ if (avp->avp_model == NULL) { /* In the case where we don't know the type of AVP, just copy the raw data or source */ - CHECK_PARAMS( avp->avp_source || avp->avp_rawdata ); + /* there might be no data if the AVP is empty */ if ( avp->avp_rawdata != NULL ) { /* the content was stored in rawdata */ memcpy(&buffer[*offset], avp->avp_rawdata, avp->avp_rawlen); *offset += PAD4(avp->avp_rawlen); - } else { + } else if ( avp->avp_source != NULL ) { /* the message was not parsed completely */ size_t datalen = avp->avp_public.avp_len - GETAVPHDRSZ(avp->avp_public.avp_flags); memcpy(&buffer[*offset], avp->avp_source, datalen);