Skip to content

Commit cc0f893

Browse files
committed
Removed unused overload of dash_if_empty that sonarcloud flags as potential buffer overflow
1 parent 8b17f36 commit cc0f893

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

src/transaction.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
15201520
ss << utils::string::dash_if_empty(
15211521
m_variableRequestHeaders.resolveFirst("Host").get())
15221522
<< " ";
1523-
ss << utils::string::dash_if_empty(this->m_clientIpAddress->c_str()) << " ";
1523+
ss << utils::string::dash_if_empty(this->m_clientIpAddress.get()) << " ";
15241524
/** TODO: Check variable */
15251525
variables::RemoteUser *r = new variables::RemoteUser("REMOTE_USER");
15261526
std::vector<const VariableValue *> l;
@@ -1531,7 +1531,7 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
15311531
delete r;
15321532

15331533
ss << utils::string::dash_if_empty(
1534-
m_variableRemoteUser.c_str());
1534+
&m_variableRemoteUser);
15351535
ss << " ";
15361536
/** TODO: Check variable */
15371537
//ss << utils::string::dash_if_empty(

src/utils/string.h

-9
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,6 @@ inline std::string dash_if_empty(const std::string *str) {
7575
}
7676

7777

78-
inline std::string dash_if_empty(const char *str) {
79-
if (str == NULL || std::strlen(str) == 0) {
80-
return "-";
81-
}
82-
83-
return std::string(str);
84-
}
85-
86-
8778
inline std::string limitTo(int amount, const std::string &str) {
8879
std::string ret;
8980

0 commit comments

Comments
 (0)