Skip to content

Commit

Permalink
Fix: m_bmqtool::Poster: remove unsafe format string passed (#603)
Browse files Browse the repository at this point in the history
Signed-off-by: sameep-git <[email protected]>
Signed-off-by: Sameep Shah <[email protected]>
Co-authored-by: Evgeny Malygin <[email protected]>
  • Loading branch information
sameep-git and 678098 authored Feb 7, 2025
1 parent d9f8b65 commit 665144f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/applications/bmqtool/m_bmqtool_poster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ void PostingContext::postNext()
}

if (!d_parameters_p->sequentialMessagePattern().empty()) {
char buffer[128];
length = snprintf(
buffer,
sizeof(buffer),
d_parameters_p->sequentialMessagePattern().c_str(),
d_numMessagesPosted);
msg.setDataRef(buffer, length);
char buffer[16];
bsl::string messageData(d_allocator_p);
length = snprintf(buffer,
sizeof(buffer),
"%09d",
d_numMessagesPosted);
messageData = d_parameters_p->sequentialMessagePattern();
messageData.append(buffer);
msg.setDataRef(messageData.c_str(), messageData.length());
}
else {
// Insert latency if required...
Expand Down
4 changes: 2 additions & 2 deletions src/integration-tests/test_puts_retransmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def error(test_logger, prefix, p1, p2=None):
+ re.escape(uri[0]) # queue url
+ r"\|(.+)\|" # |GUID|
+ r"msg\s*" # "msg"
+ r"(\d+)\|"
+ r"(\d+)"
) # %d

re_confirm = re.compile(
Expand Down Expand Up @@ -409,7 +409,7 @@ def start_producer(self, after=BACKLOG_MESSAGES):
"--queueuri",
self.uri,
"--messagepattern",
"msg%10d|",
"msg",
f"--messageProperties={self.mps}",
"--log",
producer_log,
Expand Down

0 comments on commit 665144f

Please sign in to comment.