Skip to content

Commit 09ee847

Browse files
authored
Merge pull request #72 from sy-c/master
fix: stop assuming NUL-terminated input from DimRpcParallel::getString()
2 parents a3aff12 + aa61a93 commit 09ee847

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/DimServices/DimServices.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ inline void rtrim(std::string &s) {
101101

102102
void StringRpcServer::rpcHandler()
103103
{
104-
alfDebugLog.info("Request received on %s : %s",mServiceName.c_str(),getString());
104+
// build a safe string from DIM input. Parent method getString() is unsafe, not guarateed to be nul-terminated
105+
std::string inputString;
106+
if (auto data = getString(); data && getSize() > 0) {
107+
inputString.assign(data, getSize());
108+
}
109+
110+
alfDebugLog.info("Request received on %s : %s",mServiceName.c_str(),inputString.c_str());
105111
try {
106-
auto returnValue = mCallback(std::string(getString()));
112+
auto returnValue = mCallback(inputString);
107113
setDataString(makeSuccessString(returnValue), *this);
108114
rtrim(returnValue);
109115
alfDebugLog.info("Request completed: %s", returnValue.c_str());

0 commit comments

Comments
 (0)