|
|
|
@ -210,6 +210,14 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
|
|
|
|
|
case 0x84: /* BIT STRING */
|
|
|
|
|
if (MmsValue_getType(value) == MMS_BIT_STRING) {
|
|
|
|
|
int padding = buffer[bufPos];
|
|
|
|
|
|
|
|
|
|
if (padding > 7) {
|
|
|
|
|
if (DEBUG_GOOSE_SUBSCRIBER)
|
|
|
|
|
printf("GOOSE_SUBSCRIBER: invalid bit-string (padding not plausible)\n");
|
|
|
|
|
|
|
|
|
|
pe = GOOSE_PARSE_ERROR_INVALID_PADDING;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
int bitStringLength = (8 * (elementLength - 1)) - padding;
|
|
|
|
|
if (bitStringLength == value->value.bitString.size) {
|
|
|
|
|
memcpy(value->value.bitString.buf, buffer + bufPos + 1,
|
|
|
|
@ -219,6 +227,7 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
|
|
|
|
|
pe = GOOSE_PARSE_ERROR_LENGTH_MISMATCH;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
pe = GOOSE_PARSE_ERROR_TYPE_MISMATCH;
|
|
|
|
|
}
|
|
|
|
@ -362,8 +371,10 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (elementIndex <= maxIndex) {
|
|
|
|
|
if (pe == GOOSE_PARSE_ERROR_NO_ERROR) {
|
|
|
|
|
pe = GOOSE_PARSE_ERROR_UNDERFLOW;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (DEBUG_GOOSE_SUBSCRIBER) {
|
|
|
|
|
switch (pe) {
|
|
|
|
@ -388,6 +399,8 @@ parseAllData(uint8_t* buffer, int allDataLength, MmsValue* dataSetValues)
|
|
|
|
|
case GOOSE_PARSE_ERROR_LENGTH_MISMATCH:
|
|
|
|
|
printf("GOOSE_SUBSCRIBER: Message contains value of wrong length!\n");
|
|
|
|
|
break;
|
|
|
|
|
case GOOSE_PARSE_ERROR_INVALID_PADDING:
|
|
|
|
|
printf("GOOSE_SUBSCRIBER: Malformed message: invalid padding!\n");
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -500,7 +513,16 @@ parseAllDataUnknownValue(GooseSubscriber self, uint8_t* buffer, int allDataLengt
|
|
|
|
|
case 0x83: /* boolean */
|
|
|
|
|
if (DEBUG_GOOSE_SUBSCRIBER)
|
|
|
|
|
printf("GOOSE_SUBSCRIBER: found boolean\n");
|
|
|
|
|
|
|
|
|
|
if (elementLength > 0) {
|
|
|
|
|
value = MmsValue_newBoolean(BerDecoder_decodeBoolean(buffer, bufPos));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (DEBUG_GOOSE_SUBSCRIBER)
|
|
|
|
|
printf("GOOSE_SUBSCRIBER: invalid length for boolean\n");
|
|
|
|
|
|
|
|
|
|
goto exit_with_error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|