summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Elliott <elliottc@objectcomputing.com>2022-12-08 08:48:01 -0600
committerChad Elliott <elliottc@objectcomputing.com>2022-12-08 08:48:01 -0600
commitb222c09aa3e259839ca2c22c5a033bf29dcebf38 (patch)
tree562d300a9f70e5c59fb487bd3fbda6c10f88aaba
parent37fe55c3ad443ba5d2bd2a6ecd7060db349151f3 (diff)
downloadATCD-b222c09aa3e259839ca2c22c5a033bf29dcebf38.tar.gz
Increased the final buffer size (in the info method) to accommodate the maximum possible string size. (ubuntu 20 - gcc 10 warning)
-rw-r--r--ACE/ace/Acceptor.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/ACE/ace/Acceptor.cpp b/ACE/ace/Acceptor.cpp
index 624e69cd82f..31cfe1db91f 100644
--- a/ACE/ace/Acceptor.cpp
+++ b/ACE/ace/Acceptor.cpp
@@ -830,7 +830,6 @@ ACE_Strategy_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::info (ACE_TCHAR **strp,
{
ACE_TRACE ("ACE_Strategy_Acceptor::info");
- ACE_TCHAR buf[BUFSIZ];
ACE_TCHAR service_addr_str[BUFSIZ];
typename PEER_ACCEPTOR::PEER_ADDR addr;
@@ -840,8 +839,17 @@ ACE_Strategy_Acceptor<SVC_HANDLER, PEER_ACCEPTOR>::info (ACE_TCHAR **strp,
sizeof service_addr_str) == -1)
return -1;
- // @@ Should add the protocol in...
- ACE_OS::snprintf (buf, BUFSIZ,
+ //
+ // gcc10 complains that it is possible that buf could be truncated by up to
+ // 6 bytes in this call to snprintf. Technically, this is possible
+ // (however unlikely that may be). Since service_addr_str is defined to be
+ // of size BUFSIZ, gcc assumes that the string could actually be BUFSIZ in
+ // length. That makes the possible total length of the combined string
+ // (given the size of the literal string constants) 5 + BUFSIZE + 1.
+ //
+ const size_t additional = 6;
+ ACE_TCHAR buf[BUFSIZ + additional];
+ ACE_OS::snprintf (buf, sizeof buf,
ACE_TEXT ("%s\t %s #%s\n"),
this->service_name_ == 0
? ACE_TEXT ("<unknown>")