Fix null char snprintf bug in host on file
Change-Id: I337fa2c810300c920cbc7373349d32a757359497
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/host_check_main.cpp b/host_check_main.cpp
index 5645b8e..eec4acc 100644
--- a/host_check_main.cpp
+++ b/host_check_main.cpp
@@ -130,7 +130,8 @@
// Create file for host instance and create in filesystem to indicate
// to services that host is running
auto size = std::snprintf(nullptr,0,HOST_RUNNING_FILE,0);
- std::unique_ptr<char[]> buf(new char[size+1]);
+ size++; // null
+ std::unique_ptr<char[]> buf(new char[size]);
std::snprintf(buf.get(),size,HOST_RUNNING_FILE,0);
std::ofstream outfile(buf.get());
outfile.close();