mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 21:36:00 +03:00
Fix msc_who_am_i() to return pointer to a valid C string
Previously this function was unusable as it returned pointer to some garbage data.
This commit is contained in:
parent
3fa3094eee
commit
ebc068b8ce
@ -278,7 +278,7 @@ class ModSecurity {
|
||||
ModSecurity();
|
||||
~ModSecurity();
|
||||
|
||||
static const std::string whoAmI();
|
||||
const std::string& whoAmI();
|
||||
void setConnectorInformation(std::string connector);
|
||||
void setServerLogCb(ModSecLogCb cb);
|
||||
/**
|
||||
@ -304,6 +304,7 @@ class ModSecurity {
|
||||
|
||||
private:
|
||||
std::string m_connector;
|
||||
std::string m_whoami;
|
||||
ModSecLogCb m_logCb;
|
||||
int m_logProperties;
|
||||
};
|
||||
|
@ -61,6 +61,7 @@ namespace modsecurity {
|
||||
*/
|
||||
ModSecurity::ModSecurity()
|
||||
: m_connector(""),
|
||||
m_whoami(""),
|
||||
#ifdef WITH_LMDB
|
||||
m_global_collection(new collection::backend::LMDB()),
|
||||
m_resource_collection(new collection::backend::LMDB()),
|
||||
@ -116,7 +117,7 @@ ModSecurity::~ModSecurity() {
|
||||
* update it, make it in a fashion that won't break the existent parsers.
|
||||
* (e.g. adding extra information _only_ to the end of the string)
|
||||
*/
|
||||
const std::string ModSecurity::whoAmI() {
|
||||
const std::string& ModSecurity::whoAmI() {
|
||||
std::string platform("Unknown platform");
|
||||
|
||||
#if AIX
|
||||
@ -139,8 +140,11 @@ const std::string ModSecurity::whoAmI() {
|
||||
platform = "Windows";
|
||||
#endif
|
||||
|
||||
return std::string("ModSecurity v" MODSECURITY_VERSION \
|
||||
" (" + platform + ")");
|
||||
if (m_whoami.empty()) {
|
||||
m_whoami = "ModSecurity v" MODSECURITY_VERSION " (" + platform + ")";
|
||||
}
|
||||
|
||||
return m_whoami;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user