summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Geissler <andrewg@us.ibm.com>2017-05-09 13:54:10 -0500
committerAndrew Geissler <andrewg@us.ibm.com>2017-05-09 13:54:10 -0500
commit0135bd5b3c10efe8d4df0f268602a0e0900d3650 (patch)
tree1a3c6ed3e643e4fc35cb4c2290922f9616731623
parentd5ac63507a47010f51ce857bd680c2f655380841 (diff)
downloadphosphor-state-manager-0135bd5b3c10efe8d4df0f268602a0e0900d3650.tar.gz
phosphor-state-manager-0135bd5b3c10efe8d4df0f268602a0e0900d3650.zip
Fix null char snprintf bug in host on file
Change-Id: I337fa2c810300c920cbc7373349d32a757359497 Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
-rw-r--r--host_check_main.cpp3
1 files changed, 2 insertions, 1 deletions
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 @@ int main(int argc, char *argv[])
// 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();
OpenPOWER on IntegriCloud