Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/DimServices/DimServices.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,15 @@ inline void rtrim(std::string &s) {

void StringRpcServer::rpcHandler()
{
alfDebugLog.info("Request received on %s : %s",mServiceName.c_str(),getString());
// build a safe string from DIM input. Parent method getString() is unsafe, not guarateed to be nul-terminated
std::string inputString;
if (auto data = getString(); data && getSize() > 0) {
inputString.assign(data, getSize());
}

alfDebugLog.info("Request received on %s : %s",mServiceName.c_str(),inputString.c_str());
try {
auto returnValue = mCallback(std::string(getString()));
auto returnValue = mCallback(inputString);
setDataString(makeSuccessString(returnValue), *this);
rtrim(returnValue);
alfDebugLog.info("Request completed: %s", returnValue.c_str());
Expand Down