From 15119d0a6603ddf63d062b685f5c892975e8422c Mon Sep 17 00:00:00 2001 From: Chris Fretz Date: Mon, 20 Apr 2020 19:52:57 +0000 Subject: [PATCH] Fixed an issue around unterminated input strings In the rapidjson parser --- CMakeLists.txt | 2 +- include/dart.h | 2 +- include/dart/connector/json.tcc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43ecd0b..4edadcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_policy(SET CMP0025 NEW) cmake_policy(SET CMP0048 NEW) # Name the project. -project(libdart VERSION 1.2.1) +project(libdart VERSION 1.2.2) cmake_minimum_required(VERSION 3.1.0) include(CheckIncludeFileCXX) diff --git a/include/dart.h b/include/dart.h index 894049e..8398d51 100644 --- a/include/dart.h +++ b/include/dart.h @@ -56,7 +56,7 @@ static_assert(false, "libdart requires a c++14 enabled compiler."); // Version macros for conditional compilation/feature checks. #define DART_MAJOR_VERSION 1 #define DART_MINOR_VERSION 2 -#define DART_PATCH_VERSION 1 +#define DART_PATCH_VERSION 2 /*----- Type Declarations -----*/ diff --git a/include/dart/connector/json.tcc b/include/dart/connector/json.tcc index a50df76..acc8322 100644 --- a/include/dart/connector/json.tcc +++ b/include/dart/connector/json.tcc @@ -143,7 +143,7 @@ namespace dart { detail::heap_parser context; // Parse! - rapidjson::StringStream ss(json.data()); + rapidjson::MemoryStream ss(json.data(), json.size()); if (reader.Parse(ss, context)) { return context.curr_obj; } else { @@ -152,7 +152,7 @@ namespace dart { std::string errmsg = "dart::heap could not parse the given string due to: \""; errmsg += rapidjson::GetParseError_En(err); errmsg += "\" near \""; - errmsg += std::string {json.substr(off ? off - 1 : off, 10)}; + errmsg += std::string {json.substr(off ? off - 1 : off, off + 10 < json.size() ? 10 : shim::string_view::npos)}; errmsg += "\""; throw parse_error(errmsg.data()); }