diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c8b56967..fdabf42e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +## [6.0.1] - 2019-09-05 + +- IXCobraConnection / pdu handlers can crash if they receive json data which is not an object + ## [6.0.0] - 2019-09-04 - all client autobahn test should pass ! diff --git a/ws/ixcobra/IXCobraConnection.cpp b/ws/ixcobra/IXCobraConnection.cpp index 8e6b1b7b..979925c7 100644 --- a/ws/ixcobra/IXCobraConnection.cpp +++ b/ws/ixcobra/IXCobraConnection.cpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace ix @@ -300,6 +301,8 @@ namespace ix // bool CobraConnection::handleHandshakeResponse(const Json::Value& pdu) { + if (!pdu.isObject()) return false; + if (!pdu.isMember("body")) return false; Json::Value body = pdu["body"]; @@ -349,6 +352,8 @@ namespace ix bool CobraConnection::handleSubscriptionResponse(const Json::Value& pdu) { + if (!pdu.isObject()) return false; + if (!pdu.isMember("body")) return false; Json::Value body = pdu["body"]; @@ -365,6 +370,8 @@ namespace ix bool CobraConnection::handleUnsubscriptionResponse(const Json::Value& pdu) { + if (!pdu.isObject()) return false; + if (!pdu.isMember("body")) return false; Json::Value body = pdu["body"]; @@ -381,6 +388,8 @@ namespace ix bool CobraConnection::handleSubscriptionData(const Json::Value& pdu) { + if (!pdu.isObject()) return false; + if (!pdu.isMember("body")) return false; Json::Value body = pdu["body"]; @@ -407,6 +416,8 @@ namespace ix bool CobraConnection::handlePublishResponse(const Json::Value& pdu) { + if (!pdu.isObject()) return false; + if (!pdu.isMember("id")) return false; Json::Value id = pdu["id"];