jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/onomondo-ipa/+/43028?usp=email )
Change subject: V1.2: Add size constraint to EimConfigurationData.eimId ......................................................................
V1.2: Add size constraint to EimConfigurationData.eimId
The size constraint has no impact on the existing code, because it only reads string data from structure.
Reference: SGP.32 Section 2.11.1.1.1
Related: SYS#8101 Change-Id: Iafe940876763215a28b9f9067eda090f25ad836c --- M asn1/SGP32Definitions.asn M src/ipa/libasn/EimConfigurationData.c 2 files changed, 42 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/onomondo-ipa refs/changes/28/43028/1
diff --git a/asn1/SGP32Definitions.asn b/asn1/SGP32Definitions.asn index dc09a83..a9d18b4 100644 --- a/asn1/SGP32Definitions.asn +++ b/asn1/SGP32Definitions.asn @@ -46,7 +46,7 @@ -- Section 2.11.1.1.1 -- ASN1START EimConfigurationData ::= SEQUENCE { - eimId [0] UTF8String, -- eimId of eIM + eimId [0] UTF8String (SIZE(1..128)), -- eimId of eIM eimFqdn [1] UTF8String OPTIONAL, -- FQDN of eIM eimIdType [2] EimIdType OPTIONAL, counterValue [3] INTEGER OPTIONAL, -- initial counterValue for the eIM diff --git a/src/ipa/libasn/EimConfigurationData.c b/src/ipa/libasn/EimConfigurationData.c index d01e003..2ca5ed5 100644 --- a/src/ipa/libasn/EimConfigurationData.c +++ b/src/ipa/libasn/EimConfigurationData.c @@ -7,6 +7,38 @@
#include "EimConfigurationData.h"
+static int +memb_eimId_constraint_1(const asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_constraint_failed_f *ctfailcb, void *app_key) { + const UTF8String_t *st = (const UTF8String_t *)sptr; + size_t size; + + if(!sptr) { + ASN__CTFAIL(app_key, td, sptr, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + size = UTF8String_length(st); + if((ssize_t)size < 0) { + ASN__CTFAIL(app_key, td, sptr, + "%s: UTF-8: broken encoding (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + if((size >= 1 && size <= 128)) { + /* Constraint check succeeded */ + return 0; + } else { + ASN__CTFAIL(app_key, td, sptr, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } +} + static asn_oer_constraints_t asn_OER_type_eimPublicKeyData_constr_7 CC_NOTUSED = { { 0, 0 }, -1}; @@ -23,6 +55,14 @@ { APC_UNCONSTRAINED, -1, -1, 0, 0 }, 0, 0 /* No PER value map */ }; +static asn_oer_constraints_t asn_OER_memb_eimId_constr_2 CC_NOTUSED = { + { 0, 0 }, + -1 /* (SIZE(0..MAX)) */}; +static asn_per_constraints_t asn_PER_memb_eimId_constr_2 CC_NOTUSED = { + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + 0, 0 /* No PER value map */ +}; static asn_TYPE_member_t asn_MBR_eimPublicKeyData_7[] = { { ATF_NOFLAGS, 0, offsetof(struct EimConfigurationData__eimPublicKeyData, choice.eimPublicKey), (ASN_TAG_CLASS_CONTEXT | (0 << 2)), @@ -127,7 +167,7 @@ -1, /* IMPLICIT tag at current level */ &asn_DEF_UTF8String, 0, - { 0, 0, 0 }, + { &asn_OER_memb_eimId_constr_2, &asn_PER_memb_eimId_constr_2, memb_eimId_constraint_1 }, 0, 0, /* No default value */ "eimId" },