refactor(pubsub): Don't expose the DataSetMessage size array to the outside

A user who only decodes the headers and manually looks at the payload
will have access to the size array anyway.
This commit is contained in:
Julius Pfrommer 2025-05-27 07:54:58 +02:00 committed by Julius Pfrommer
parent b5ed28c47b
commit 6c7dac7ef6
2 changed files with 6 additions and 6 deletions

View File

@ -187,7 +187,6 @@ typedef struct {
UA_Boolean payloadHeaderEnabled;
UA_Byte messageCount;
UA_UInt16 dataSetWriterIds[UA_NETWORKMESSAGE_MAXMESSAGECOUNT];
UA_UInt16 dataSetMessageSizes[UA_NETWORKMESSAGE_MAXMESSAGECOUNT];
/* TODO: Add support for Discovery Messages */
UA_NetworkMessageType networkMessageType;

View File

@ -702,17 +702,18 @@ UA_NetworkMessage_decodePayload(PubSubDecodeCtx *ctx,
/* Get the payload sizes */
UA_StatusCode rv = UA_STATUSCODE_GOOD;
UA_UInt16 dataSetMessageSizes[UA_NETWORKMESSAGE_MAXMESSAGECOUNT];
if(nm->messageCount == 1) {
/* Not contained in the message, but can be inferred from the
* remaining message length */
UA_UInt16 size = (UA_UInt16)(ctx->ctx.end - ctx->ctx.pos);
nm->dataSetMessageSizes[0] = size;
dataSetMessageSizes[0] = size;
} else {
if(nm->payloadHeaderEnabled) {
/* Decode from the message */
for(size_t i = 0; i < nm->messageCount; i++) {
rv |= _DECODE_BINARY(&nm->dataSetMessageSizes[i], UINT16);
if(nm->dataSetMessageSizes[i] == 0)
rv |= _DECODE_BINARY(&dataSetMessageSizes[i], UINT16);
if(dataSetMessageSizes[i] == 0)
return UA_STATUSCODE_BADDECODINGERROR;
}
UA_CHECK_STATUS(rv, return rv);
@ -720,7 +721,7 @@ UA_NetworkMessage_decodePayload(PubSubDecodeCtx *ctx,
/* If no PayloadHeader is defined, then assume the EncodingOptions
* reflect the DataSetMessages */
for(size_t i = 0; i < nm->messageCount; i++)
nm->dataSetMessageSizes[i] = ctx->eo.metaData[i].configuredSize;
dataSetMessageSizes[i] = ctx->eo.metaData[i].configuredSize;
}
}
@ -730,7 +731,7 @@ UA_NetworkMessage_decodePayload(PubSubDecodeCtx *ctx,
findEncodingMetaData(&ctx->eo, nm->dataSetWriterIds[i]);
rv |= UA_DataSetMessage_decodeBinary(ctx, emd,
&nm->payload.dataSetMessages[i],
nm->dataSetMessageSizes[i]);
dataSetMessageSizes[i]);
}
return rv;