@@ -469,12 +469,15 @@ namespace
469469 " are not set." );
470470
471471 // The payload and topic are only valid within the
472- // context of the callback: make them read-only and
473- // non-capturable.
472+ // context of the callback: make them read-only,
473+ // non-capturable, and limits to the length of the
474+ // topic and payload.
474475 Capability topic{publishInfo->pTopicName };
475476 Capability payload{publishInfo->pPayload };
476477 topic.permissions () &= CHERI::Permission::Load;
478+ topic.bounds () = publishInfo->topicNameLength ;
477479 payload.permissions () &= CHERI::Permission::Load;
480+ payload.bounds () = publishInfo->payloadLength ;
478481
479482 publishCallback (topic,
480483 publishInfo->topicNameLength ,
@@ -815,7 +818,8 @@ int mqtt_publish(Timeout *t,
815818 const char *topic,
816819 size_t topicLength,
817820 const void *payload,
818- size_t payloadLength)
821+ size_t payloadLength,
822+ bool retain)
819823{
820824 if (!CHERI::check_pointer (topic, topicLength))
821825 {
@@ -872,6 +876,7 @@ int mqtt_publish(Timeout *t,
872876 publishInfo.topicNameLength = topicLength;
873877 publishInfo.pPayload = payload;
874878 publishInfo.payloadLength = payloadLength;
879+ publishInfo.retain = retain;
875880
876881 // Packet ID is needed for QoS > 0.
877882 int packetId = MQTT_GetPacketId (coreMQTTContext);
0 commit comments