- fixed problem in BER integer decoder (problem with GOOSE fixed length message decoding)

pull/331/head
Michael Zillgith 4 years ago
parent da08489bc3
commit ef1895c2be

@ -203,10 +203,9 @@ BerInteger_createFromInt64(int64_t value)
return asn1Value;
}
int /* 1 - if conversion is possible, 0 - out of range */
void
BerInteger_toInt32(Asn1PrimitiveValue* self, int32_t* nativeValue)
{
if (self->size < 5) {
uint8_t* buf = self->octets;
int i;
@ -217,17 +216,11 @@ BerInteger_toInt32(Asn1PrimitiveValue* self, int32_t* nativeValue)
for (i = 0; i < self->size; i++)
*nativeValue = (*nativeValue << 8) | buf[i];
return 1;
}
else
return 0;
}
int /* 1 - if conversion is possible, 0 - out of range */
void
BerInteger_toUint32(Asn1PrimitiveValue* self, uint32_t* nativeValue)
{
if (self->size < 6) {
uint8_t* buf = self->octets;
int i;
@ -235,17 +228,11 @@ BerInteger_toUint32(Asn1PrimitiveValue* self, uint32_t* nativeValue)
for (i = 0; i < self->size; i++)
*nativeValue = (*nativeValue << 8) | buf[i];
return 1;
}
else
return 0;
}
int /* 1 - if conversion is possible, 0 - out of range */
void
BerInteger_toInt64(Asn1PrimitiveValue* self, int64_t* nativeValue)
{
if (self->size < 9) {
uint8_t* buf = self->octets;
int i;
@ -256,10 +243,5 @@ BerInteger_toInt64(Asn1PrimitiveValue* self, int64_t* nativeValue)
for (i = 0; i < self->size; i++)
*nativeValue = (*nativeValue << 8) | buf[i];
return 1;
}
else
return 0;
}

@ -66,13 +66,13 @@ BerInteger_createInt64(void);
LIB61850_INTERNAL int
BerInteger_setInt64(Asn1PrimitiveValue* self, int64_t value);
LIB61850_INTERNAL int /* 1 - if conversion is possible, 0 - out of range */
LIB61850_INTERNAL void
BerInteger_toInt32(Asn1PrimitiveValue* self, int32_t* nativeValue);
LIB61850_INTERNAL int /* 1 - if conversion is possible, 0 - out of range */
LIB61850_INTERNAL void
BerInteger_toUint32(Asn1PrimitiveValue* self, uint32_t* nativeValue);
LIB61850_INTERNAL int /* 1 - if conversion is possible, 0 - out of range */
LIB61850_INTERNAL void
BerInteger_toInt64(Asn1PrimitiveValue* self, int64_t* nativeValue);
#ifdef __cplusplus

Loading…
Cancel
Save