From 2a539cb22c74ee898df124c02f433f141e6dd4d9 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 20 Mar 2018 13:52:19 -0700 Subject: [PATCH] ircd::json: Ensure space for null string terminator in print(). --- include/ircd/json/json.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/ircd/json/json.h b/include/ircd/json/json.h index 66f862236..f8b9f5c2e 100644 --- a/include/ircd/json/json.h +++ b/include/ircd/json/json.h @@ -125,9 +125,14 @@ ircd::json::print(const mutable_buffer &buf, if(unlikely(!size(buf))) return 0; + mutable_buffer out + { + data(buf), size(buf) - 1 + }; + const auto sv { - stringify(mutable_buffer{buf}, std::forward(t)...) + stringify(out, std::forward(t)...) }; assert(sv.size() < size(buf));