Skip to content

Commit

Permalink
iox-eclipse-iceoryx#960 Fix format string issues
Browse files Browse the repository at this point in the history
The prettyPrint() function no longer uses the unsanitized input string
as format string for wprintw(), which is potentially dangerous if that
string happens to contain '%' signs.

The printMemPoolInfo() now correctly uses '%zd' instead of '%d' to
format an output value of type size_t.
  • Loading branch information
roehling committed Nov 2, 2021
1 parent 2749f89 commit a2d75d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/introspection/source/introspection_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void IntrospectionApp::waitForUserInput(int32_t timeoutMs)
void IntrospectionApp::prettyPrint(const std::string& str, const PrettyOptions pr)
{
wattron(pad, prettyMap.find(pr)->second);
wprintw(pad, str.c_str());
wprintw(pad, "%s", str.c_str());
wattroff(pad, prettyMap.find(pr)->second);
}

Expand Down Expand Up @@ -288,7 +288,7 @@ void IntrospectionApp::printMemPoolInfo(const MemPoolIntrospectionInfo& introspe
auto& info = introspectionInfo.m_mempoolInfo[i];
if (info.m_numChunks > 0u)
{
wprintw(pad, "%*d |", memPoolWidth, i + 1u);
wprintw(pad, "%*zd |", memPoolWidth, i + 1u);
wprintw(pad, "%*d |", usedchunksWidth, info.m_usedChunks);
wprintw(pad, "%*d |", numchunksWidth, info.m_numChunks);
wprintw(pad, "%*d |", minFreechunksWidth, info.m_minFreeChunks);
Expand Down

0 comments on commit a2d75d3

Please sign in to comment.