- fix - server crashes when presentation message has no user data (LIB61850-291)(#368)

pull/331/merge
Michael Zillgith 4 years ago
parent 8918a442e0
commit 32087c47de

@ -398,10 +398,18 @@ parseNormalModeParameters(IsoPresentation* self, uint8_t* buffer, int totalLengt
self->calledPresentationSelector.size = 0;
self->callingPresentationSelector.size = 0;
bool hasUserData = false;
while (bufPos < endPos) {
uint8_t tag = buffer[bufPos++];
int len;
if (bufPos == endPos) {
if (DEBUG_PRES)
printf("PRES: invalid message\n");
return -1;
}
bufPos = BerDecoder_decodeLength(buffer, &len, bufPos, endPos);
if (bufPos < 0) {
@ -458,6 +466,9 @@ parseNormalModeParameters(IsoPresentation* self, uint8_t* buffer, int totalLengt
if (bufPos < 0)
return -1;
if (self->nextPayload.size > 0)
hasUserData = true;
break;
case 0x00: /* indefinite length end tag -> ignore */
@ -471,6 +482,13 @@ parseNormalModeParameters(IsoPresentation* self, uint8_t* buffer, int totalLengt
}
}
if (hasUserData == false) {
if (DEBUG_PRES)
printf("PRES: user-data is missing\n");
return -1;
}
return bufPos;
}

@ -308,6 +308,10 @@ IsoConnection_handleTcpConnection(IsoConnection self, bool isSingleThread)
}
}
else {
self->state = ISO_CON_STATE_STOPPED;
}
break;
case SESSION_DATA:
if (DEBUG_ISO_SERVER)

Loading…
Cancel
Save