Skip to content

Commit

Permalink
Size of data should include null terminator (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
djones6 authored and sjanuary committed Oct 23, 2017
1 parent e30bf90 commit 5a2361b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/cpuplugin/cpuplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ agentCoreFunctions CpuPlugin::aCF;
AppendCPUTime(contentss);

std::string content = contentss.str();
data->size = static_cast<uint32>(content.length()); // should data->size be a size_t?
uint32 cSize = static_cast<uint32>(content.length() + 1); // +1 to include null terminator
data->size = cSize; // should data->size be a size_t?
data->data = NewCString(content);
} else {
if (!IsValidData(instance->current)) {
Expand Down
3 changes: 2 additions & 1 deletion src/envplugin/envplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ monitordata* EnvPlugin::OnRequestData() {
AppendSystemInfo(contentss);

std::string content = contentss.str();
data->size = static_cast<uint32>(content.length()); // should data->size be a size_t?
uint32 cSize = static_cast<uint32>(content.length() + 1); // +1 to include null terminator
data->size = cSize; // should data->size be a size_t?
data->data = NewCString(content);
data->persistent = false;
aCF.logMessage(debug, "<<<EnvPlugin::OnRequestData");
Expand Down
2 changes: 1 addition & 1 deletion src/memplugin/MemoryPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ monitordata* MemoryPlugin::OnRequestData() {
if (sval) {
strcpy(sval, memorydata.c_str());

data->size = len;
data->data = sval;
data->size = len + 1; // +1 to include null terminator

}
aCF.logMessage(debug, "<<<MemoryPlugin::OnRequestData");
Expand Down

0 comments on commit 5a2361b

Please sign in to comment.