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
This commit is contained in:
daniel_peintner 2019-01-23 08:23:30 +00:00
parent 033a46dd37
commit 06a3b436bf
3 changed files with 5 additions and 4 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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);
}