mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-13 13:26:01 +03:00
Encapsulates int[N] in a class to avoid compilation issues
Depending on the compiler, there may be a compilation issue with the usage of std::unique_ptr<int[]>. Therefore encapsulating it inside a regular class.
This commit is contained in:
parent
e3b9f7c913
commit
18cdffdbca
@ -82,6 +82,22 @@ class ConfigSet {
|
||||
};
|
||||
|
||||
|
||||
class UnicodeMapHolder {
|
||||
public:
|
||||
UnicodeMapHolder() {
|
||||
memset(m_data, -1, (sizeof(int)*65536));
|
||||
};
|
||||
|
||||
int& operator[](int index) { return m_data[index]; }
|
||||
int operator[](int index) const { return m_data[index]; }
|
||||
|
||||
int at(int index) const { return m_data[index]; }
|
||||
void change(int i, int a) { m_data[i] = a; }
|
||||
|
||||
int m_data[65536];
|
||||
};
|
||||
|
||||
|
||||
class RulesProperties;
|
||||
class ConfigUnicodeMap {
|
||||
public:
|
||||
@ -106,7 +122,7 @@ class ConfigUnicodeMap {
|
||||
|
||||
bool m_set;
|
||||
double m_unicodeCodePage;
|
||||
std::shared_ptr<int[]> m_unicodeMapTable;
|
||||
std::shared_ptr<modsecurity::UnicodeMapHolder> m_unicodeMapTable;
|
||||
};
|
||||
|
||||
|
||||
|
@ -109,7 +109,7 @@ int UrlDecodeUni::inplace(unsigned char *input, uint64_t input_len,
|
||||
|
||||
if (Code >= 0 && Code <= 65535) {
|
||||
Rules *r = t->m_rules;
|
||||
hmap = r->m_unicodeMapTable.m_unicodeMapTable[Code];
|
||||
hmap = r->m_unicodeMapTable.m_unicodeMapTable->at(Code);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,20 +40,17 @@ void ConfigUnicodeMap::loadConfig(std::string f, double configCodePage,
|
||||
driver->m_unicodeMapTable.m_set = true;
|
||||
driver->m_unicodeMapTable.m_unicodeCodePage = configCodePage;
|
||||
|
||||
std::unique_ptr<int[]> a(new int[65536], std::default_delete<int[]>());
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable = std::move(a);
|
||||
memset(driver->m_unicodeMapTable.m_unicodeMapTable.get(), -1,
|
||||
(sizeof(int)*65536));
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable.reset(new modsecurity::UnicodeMapHolder());
|
||||
|
||||
/* Setting some unicode values - http://tools.ietf.org/html/rfc3490#section-3.1 */
|
||||
/* Set 0x3002 -> 0x2e */
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable[0x3002] = 0x2e;
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable->change(0x3002, 0x2e);
|
||||
/* Set 0xFF61 -> 0x2e */
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable[0xff61] = 0x2e;
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable->change(0xff61, 0x2e);
|
||||
/* Set 0xFF0E -> 0x2e */
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable[0xff0e] = 0x2e;
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable->change(0xff0e, 0x2e);
|
||||
/* Set 0x002E -> 0x2e */
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable[0x002e] = 0x2e;
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable->change(0x002e, 0x2e);
|
||||
|
||||
|
||||
std::ifstream file_stream(f, std::ios::in | std::ios::binary);
|
||||
@ -106,7 +103,7 @@ void ConfigUnicodeMap::loadConfig(std::string f, double configCodePage,
|
||||
sscanf(ucode, "%x", &code);
|
||||
sscanf(hmap, "%x", &Map);
|
||||
if (code >= 0 && code <= 65535) {
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable[code] = Map;
|
||||
driver->m_unicodeMapTable.m_unicodeMapTable->change(code, Map);
|
||||
}
|
||||
|
||||
free(mapping);
|
||||
|
Loading…
x
Reference in New Issue
Block a user