--- a/src/PosixMQ.h Wed Apr 20 02:26:44 2022 +0200
+++ b/src/PosixMQ.h Wed Apr 20 20:59:42 2022 +0200
@@ -58,7 +58,8 @@
memset(buffer, 0, MSG_SIZE + 1);
ssize_t msgSize = mq_receive(handle, buffer, MSG_SIZE, nullptr);
- if (msgSize >= 0) return std::string(buffer);
+ if (msgSize > sizeof (buffer))throw std::logic_error("Invalid PosixMQ message size.");
+ else if (msgSize >= 0) return std::string(buffer, msgSize);
else throw std::logic_error("Unable to receive PosixMQ message from " + queueName + " error: " + strerror(errno));
}