aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2015-12-18 15:17:21 +0100
committerHarald Welte <laforge@gnumonks.org>2015-12-18 15:18:13 +0100
commit04329dcbdca62edf5f254bf309963d1a69c244f3 (patch)
treef1bd6af64884862c5547b43465b9ee8b3cb227ec /src
parent629391321f10490c5b5f1edc5035ea2e5679ad3e (diff)
{hnbap,rua,ranap}_common: check for encoding errors in new_ie()
Diffstat (limited to 'src')
-rw-r--r--src/hnbap_common.c8
-rw-r--r--src/ranap_common.c26
-rw-r--r--src/rua_common.c8
3 files changed, 35 insertions, 7 deletions
diff --git a/src/hnbap_common.c b/src/hnbap_common.c
index 2cd7ee2..1c92542 100644
--- a/src/hnbap_common.c
+++ b/src/hnbap_common.c
@@ -222,6 +222,7 @@ IE_t *hnbap_new_ie(ProtocolIE_ID_t id,
{
IE_t *buff;
+ int rc;
if ((buff = CALLOC(1, sizeof(IE_t))) == NULL) {
// Possible error on malloc
@@ -231,7 +232,12 @@ IE_t *hnbap_new_ie(ProtocolIE_ID_t id,
buff->id = id;
buff->criticality = criticality;
- ANY_fromType_aper(&buff->value, type, sptr);
+ rc = ANY_fromType_aper(&buff->value, type, sptr);
+ if (rc < 0) {
+ LOGP(DMAIN, LOGL_ERROR, "Error in ANY_fromType_aper\n");
+ FREEMEM(buff);
+ return NULL;
+ }
if (asn1_xer_print)
if (xer_fprint(stdout, &asn_DEF_IE, buff) < 0) {
diff --git a/src/ranap_common.c b/src/ranap_common.c
index 8081c01..c12941c 100644
--- a/src/ranap_common.c
+++ b/src/ranap_common.c
@@ -164,8 +164,8 @@ RANAP_IE_t *ranap_new_ie(RANAP_ProtocolIE_ID_t id,
RANAP_Criticality_t criticality,
asn_TYPE_descriptor_t * type, void *sptr)
{
-
RANAP_IE_t *buff;
+ int rc;
if ((buff = CALLOC(1, sizeof(*buff))) == NULL) {
// Possible error on malloc
@@ -175,7 +175,12 @@ RANAP_IE_t *ranap_new_ie(RANAP_ProtocolIE_ID_t id,
buff->id = id;
buff->criticality = criticality;
- ANY_fromType_aper(&buff->value, type, sptr);
+ rc = ANY_fromType_aper(&buff->value, type, sptr);
+ if (rc < 0) {
+ LOGP(DMAIN, LOGL_ERROR, "Error in ANY_fromType_aper\n");
+ FREEMEM(buff);
+ return NULL;
+ }
if (asn1_xer_print)
if (xer_fprint(stdout, &asn_DEF_RANAP_IE, buff) < 0) {
@@ -192,8 +197,8 @@ RANAP_ProtocolIE_FieldPair_t *ranap_new_ie_pair(RANAP_ProtocolIE_ID_t id,
RANAP_Criticality_t criticality2,
asn_TYPE_descriptor_t *type2, void *sptr2)
{
-
RANAP_ProtocolIE_FieldPair_t *buff;
+ int rc;
if ((buff = CALLOC(1, sizeof(*buff))) == NULL) {
// Possible error on malloc
@@ -204,8 +209,19 @@ RANAP_ProtocolIE_FieldPair_t *ranap_new_ie_pair(RANAP_ProtocolIE_ID_t id,
buff->firstCriticality = criticality1;
buff->secondCriticality = criticality2;
- ANY_fromType_aper(&buff->firstValue, type1, sptr1);
- ANY_fromType_aper(&buff->secondValue, type2, sptr2);
+ rc = ANY_fromType_aper(&buff->firstValue, type1, sptr1);
+ if (rc < 0) {
+ LOGP(DMAIN, LOGL_ERROR, "Error in ANY_fromType_aper\n");
+ FREEMEM(buff);
+ return NULL;
+ }
+
+ rc = ANY_fromType_aper(&buff->secondValue, type2, sptr2);
+ if (rc < 0) {
+ LOGP(DMAIN, LOGL_ERROR, "Error in ANY_fromType_aper\n");
+ FREEMEM(buff);
+ return NULL;
+ }
if (asn1_xer_print)
if (xer_fprint(stdout, &asn_DEF_RANAP_ProtocolIE_FieldPair, buff) < 0) {
diff --git a/src/rua_common.c b/src/rua_common.c
index 3d7bacd..5809b7f 100644
--- a/src/rua_common.c
+++ b/src/rua_common.c
@@ -196,6 +196,7 @@ RUA_IE_t *rua_new_ie(RUA_ProtocolIE_ID_t id,
{
RUA_IE_t *buff;
+ int rc;
if ((buff = CALLOC(1, sizeof(*buff))) == NULL) {
// Possible error on malloc
@@ -205,7 +206,12 @@ RUA_IE_t *rua_new_ie(RUA_ProtocolIE_ID_t id,
buff->id = id;
buff->criticality = criticality;
- ANY_fromType_aper(&buff->value, type, sptr);
+ rc = ANY_fromType_aper(&buff->value, type, sptr);
+ if (rc < 0) {
+ LOGP(DMAIN, LOGL_ERROR, "Error in ANY_fromType_aper\n");
+ FREEMEM(buff);
+ return NULL;
+ }
if (asn1_xer_print)
if (xer_fprint(stdout, &asn_DEF_RUA_IE, buff) < 0) {