mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +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();
|
||||||
~ModSecurity();
|
~ModSecurity();
|
||||||
|
|
||||||
static const std::string whoAmI();
|
const std::string& whoAmI();
|
||||||
void setConnectorInformation(std::string connector);
|
void setConnectorInformation(std::string connector);
|
||||||
void setServerLogCb(ModSecLogCb cb);
|
void setServerLogCb(ModSecLogCb cb);
|
||||||
/**
|
/**
|
||||||
@ -304,6 +304,7 @@ class ModSecurity {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_connector;
|
std::string m_connector;
|
||||||
|
std::string m_whoami;
|
||||||
ModSecLogCb m_logCb;
|
ModSecLogCb m_logCb;
|
||||||
int m_logProperties;
|
int m_logProperties;
|
||||||
};
|
};
|
||||||
|
@ -61,6 +61,7 @@ namespace modsecurity {
|
|||||||
*/
|
*/
|
||||||
ModSecurity::ModSecurity()
|
ModSecurity::ModSecurity()
|
||||||
: m_connector(""),
|
: m_connector(""),
|
||||||
|
m_whoami(""),
|
||||||
#ifdef WITH_LMDB
|
#ifdef WITH_LMDB
|
||||||
m_global_collection(new collection::backend::LMDB()),
|
m_global_collection(new collection::backend::LMDB()),
|
||||||
m_resource_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.
|
* 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)
|
* (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");
|
std::string platform("Unknown platform");
|
||||||
|
|
||||||
#if AIX
|
#if AIX
|
||||||
@ -139,8 +140,11 @@ const std::string ModSecurity::whoAmI() {
|
|||||||
platform = "Windows";
|
platform = "Windows";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return std::string("ModSecurity v" MODSECURITY_VERSION \
|
if (m_whoami.empty()) {
|
||||||
" (" + platform + ")");
|
m_whoami = "ModSecurity v" MODSECURITY_VERSION " (" + platform + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_whoami;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user