From 4109da361be0db2a55b56923d62a581c72eab1be Mon Sep 17 00:00:00 2001 From: daniel_peintner Date: Wed, 23 Jan 2019 08:23:30 +0000 Subject: [PATCH] fix: set fixed size of big integer container git-svn-id: https://svn.code.sf.net/p/openv2g/code/trunk@113 d9f2db14-54d0-4bde-b00c-16405c910529 --- src/iso1/iso1EXIDatatypes.h | 5 +++-- src/iso1/iso1EXIDatatypesDecoder.c | 2 +- src/iso1/iso1EXIDatatypesEncoder.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/iso1/iso1EXIDatatypes.h b/src/iso1/iso1EXIDatatypes.h index 6fe64a4..71ad320 100644 --- a/src/iso1/iso1EXIDatatypes.h +++ b/src/iso1/iso1EXIDatatypes.h @@ -464,6 +464,7 @@ struct iso1KeyValueType { /* Complex type name='http://www.w3.org/2000/09/xmldsig#,X509IssuerSerialType', base type name='anyType', content type='ELEMENT', isAbstract='false', hasTypeId='false', final='0', block='0', particle='("http://www.w3.org/2000/09/xmldsig#":X509IssuerName,"http://www.w3.org/2000/09/xmldsig#":X509SerialNumber)', derivedBy='RESTRICTION'. */ #define iso1X509IssuerSerialType_X509IssuerName_CHARACTERS_SIZE 50 + EXTRA_CHAR +#define iso1X509IssuerSerialType_X509SerialNumber_BYTES_SIZE 20 uint8_t characters[20]; struct iso1X509IssuerSerialType { /* element: "http://www.w3.org/2000/09/xmldsig#":X509IssuerName, http://www.w3.org/2001/XMLSchema,string */ @@ -477,11 +478,11 @@ struct iso1X509IssuerSerialType { /** a sign value */ int negative; /* container size */ - size_t size; + /* size_t size; iso1X509IssuerSerialType_X509SerialNumber_BYTES_SIZE */ /** array data container */ /* For negative values, the Unsigned Integer holds the * magnitude of the value minus 1 */ - uint8_t* data; + uint8_t data[iso1X509IssuerSerialType_X509SerialNumber_BYTES_SIZE]; /** array length (len <= size) */ size_t len; } X509SerialNumber; diff --git a/src/iso1/iso1EXIDatatypesDecoder.c b/src/iso1/iso1EXIDatatypesDecoder.c index ba4ade9..758d761 100644 --- a/src/iso1/iso1EXIDatatypesDecoder.c +++ b/src/iso1/iso1EXIDatatypesDecoder.c @@ -8060,7 +8060,7 @@ static int decode_iso1X509IssuerSerialType(bitstream_t* stream, struct iso1X509I errn = decodeNBitUnsignedInteger(stream, 1, &eventCode); if(errn == 0) { if(eventCode == 0) { - errn = decodeIntegerBig(stream, &iso1X509IssuerSerialType->X509SerialNumber.negative, iso1X509IssuerSerialType->X509SerialNumber.size, iso1X509IssuerSerialType->X509SerialNumber.data, &iso1X509IssuerSerialType->X509SerialNumber.len); + errn = decodeIntegerBig(stream, &iso1X509IssuerSerialType->X509SerialNumber.negative, iso1X509IssuerSerialType_X509SerialNumber_BYTES_SIZE, iso1X509IssuerSerialType->X509SerialNumber.data, &iso1X509IssuerSerialType->X509SerialNumber.len); } else { /* Second level event (e.g., xsi:type, xsi:nil, ...) */ errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS; diff --git a/src/iso1/iso1EXIDatatypesEncoder.c b/src/iso1/iso1EXIDatatypesEncoder.c index 4c2db21..8f9789d 100644 --- a/src/iso1/iso1EXIDatatypesEncoder.c +++ b/src/iso1/iso1EXIDatatypesEncoder.c @@ -5815,7 +5815,7 @@ static int encode_iso1X509IssuerSerialType(bitstream_t* stream, struct iso1X509I errn = encodeNBitUnsignedInteger(stream, 1, 0); if(errn == 0) { /* errn = encodeInteger64(stream, iso1X509IssuerSerialType->X509SerialNumber); */ - errn = encodeIntegerBig(stream, iso1X509IssuerSerialType->X509SerialNumber.negative, iso1X509IssuerSerialType->X509SerialNumber.size, iso1X509IssuerSerialType->X509SerialNumber.data, iso1X509IssuerSerialType->X509SerialNumber.len); + errn = encodeIntegerBig(stream, iso1X509IssuerSerialType->X509SerialNumber.negative, iso1X509IssuerSerialType_X509SerialNumber_BYTES_SIZE, iso1X509IssuerSerialType->X509SerialNumber.data, iso1X509IssuerSerialType->X509SerialNumber.len); /* valid EE */ errn = encodeNBitUnsignedInteger(stream, 1, 0); }