Skip to content

Commit

Permalink
Removed unused overload of dash_if_empty that sonarcloud flags as pot…
Browse files Browse the repository at this point in the history
…ential buffer overflow
  • Loading branch information
eduar-hte committed Aug 9, 2024
1 parent 8b17f36 commit b77fe4e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
ss << utils::string::dash_if_empty(
m_variableRequestHeaders.resolveFirst("Host").get())
<< " ";
ss << utils::string::dash_if_empty(this->m_clientIpAddress->c_str()) << " ";
ss << utils::string::dash_if_empty(&this->m_clientIpAddress) << " ";

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, wo curl)

'std::string modsecurity::utils::string::dash_if_empty(const std::string *)': cannot convert argument 1 from 'std::shared_ptr<std::string> *' to 'const std::string *' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, wo curl)

built-in operator '<<' cannot be applied to an operand of type 'std::stringstream' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, wo lua)

'std::string modsecurity::utils::string::dash_if_empty(const std::string *)': cannot convert argument 1 from 'std::shared_ptr<std::string> *' to 'const std::string *' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, wo lua)

built-in operator '<<' cannot be applied to an operand of type 'std::stringstream' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, wo maxmind)

'std::string modsecurity::utils::string::dash_if_empty(const std::string *)': cannot convert argument 1 from 'std::shared_ptr<std::string> *' to 'const std::string *' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, wo maxmind)

built-in operator '<<' cannot be applied to an operand of type 'std::stringstream' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, wo libxml)

'std::string modsecurity::utils::string::dash_if_empty(const std::string *)': cannot convert argument 1 from 'std::shared_ptr<std::string> *' to 'const std::string *' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, wo libxml)

built-in operator '<<' cannot be applied to an operand of type 'std::stringstream' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, wo lmdb)

'std::string modsecurity::utils::string::dash_if_empty(const std::string *)': cannot convert argument 1 from 'std::shared_ptr<std::string> *' to 'const std::string *' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, wo lmdb)

built-in operator '<<' cannot be applied to an operand of type 'std::stringstream' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, full)

'std::string modsecurity::utils::string::dash_if_empty(const std::string *)': cannot convert argument 1 from 'std::shared_ptr<std::string> *' to 'const std::string *' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]

Check failure on line 1523 in src/transaction.cc

View workflow job for this annotation

GitHub Actions / Windows (x64, full)

built-in operator '<<' cannot be applied to an operand of type 'std::stringstream' [D:\a\ModSecurity\ModSecurity\build\win32\build\libModSecurity.vcxproj]
/** TODO: Check variable */
variables::RemoteUser *r = new variables::RemoteUser("REMOTE_USER");
std::vector<const VariableValue *> l;
Expand All @@ -1531,7 +1531,7 @@ std::string Transaction::toOldAuditLogFormatIndex(const std::string &filename,
delete r;

ss << utils::string::dash_if_empty(
m_variableRemoteUser.c_str());
&m_variableRemoteUser);
ss << " ";
/** TODO: Check variable */
//ss << utils::string::dash_if_empty(
Expand Down
9 changes: 0 additions & 9 deletions src/utils/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,6 @@ inline std::string dash_if_empty(const std::string *str) {
}


inline std::string dash_if_empty(const char *str) {
if (str == NULL || std::strlen(str) == 0) {
return "-";
}

return std::string(str);
}


inline std::string limitTo(int amount, const std::string &str) {
std::string ret;

Expand Down

0 comments on commit b77fe4e

Please sign in to comment.