From badbe8cf1f2777c5879dbd7a189ce98a764dda58 Mon Sep 17 00:00:00 2001 From: Matthew Fredrickson Date: Tue, 12 Jul 2005 20:15:20 +0000 Subject: [PATCH] Fix for non constructed number component git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@240 2fbb986a-6c06-0410-b554-c9c1f0a7f128 --- pri_facility.c | 27 +++++++++++++++++++++++++++ pri_facility.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/pri_facility.c b/pri_facility.c index b6c4b56..8912841 100755 --- a/pri_facility.c +++ b/pri_facility.c @@ -231,6 +231,26 @@ int asn1_string_encode(unsigned char asn1_type, void *data, int len, int max_len return 2 + src_len; } +int asn1_copy_string(char * buf, int buflen, struct rose_component *comp) +{ + int res; + int datalen; + + if ((comp->len > buflen) && (comp->len != ASN1_LEN_INDEF)) + return -1; + + if (comp->len == ASN1_LEN_INDEF) { + datalen = strlen(comp->data); + res = datalen + 2; + } else + res = datalen = comp->len; + + memcpy(buf, comp->data, datalen); + buf[datalen] = 0; + + return res; +} + static int rose_number_digits_decode(struct pri *pri, q931_call *call, unsigned char *data, int len, struct addressingdataelements_presentednumberunscreened *value) { int i = 0; @@ -309,6 +329,13 @@ static int rose_address_decode(struct pri *pri, q931_call *call, unsigned char * value->npi = PRI_NPI_UNKNOWN; value->ton = PRI_TON_UNKNOWN; break; + case (ASN1_CONTEXT_SPECIFIC | ASN1_TAG_0): /* [0] unknownPartyNumber */ + res = asn1_copy_string(value->partyaddress, sizeof(value->partyaddress), comp); + if (res < 0) + return -1; + value->npi = PRI_NPI_UNKNOWN; + value->ton = PRI_TON_UNKNOWN; + break; case (ASN1_CONTEXT_SPECIFIC | ASN1_CONSTRUCTOR | ASN1_TAG_1): /* [1] publicPartyNumber */ res = rose_public_party_number_decode(pri, call, comp->data, comp->len, value); if (res < 0) diff --git a/pri_facility.h b/pri_facility.h index 1c1ec56..f9e9b19 100755 --- a/pri_facility.h +++ b/pri_facility.h @@ -232,6 +232,8 @@ struct rose_component { /* Decoder for the invoke part of a ROSE request */ extern int rose_invoke_decode(struct pri *pri, struct q931_call *call, unsigned char *data, int len); +extern int asn1_copy_string(char * buf, int buflen, struct rose_component *comp); + extern int asn1_string_encode(unsigned char asn1_type, void *data, int len, int max_len, void *src, int src_len); /* Get Name types from ASN.1 */