|
27 | 27 |
|
28 | 28 | #undef LMDB_STDOUT_COUT
|
29 | 29 |
|
30 |
| - |
31 | 30 | namespace modsecurity {
|
32 | 31 | namespace collection {
|
33 | 32 | namespace backend {
|
34 | 33 |
|
35 | 34 |
|
36 | 35 | #ifdef WITH_LMDB
|
37 | 36 |
|
38 |
| - |
39 |
| -LMDB::LMDB() : Collection(""), m_env(NULL) { |
| 37 | +LMDB::LMDB(std::string name) : |
| 38 | + Collection(name), m_env(NULL) { |
40 | 39 | mdb_env_create(&m_env);
|
41 | 40 | mdb_env_open(m_env, "./modsec-shared-collections",
|
42 | 41 | MDB_WRITEMAP | MDB_NOSUBDIR, 0664);
|
@@ -121,7 +120,7 @@ void LMDB::lmdb_debug(int rc, std::string op, std::string scope) {
|
121 | 120 | }
|
122 | 121 | std::cout << std::endl;
|
123 | 122 | } else if (op == "del") {
|
124 |
| - td::cout << scope << ", delete procedure failed: "; |
| 123 | + std::cout << scope << ", delete procedure failed: "; |
125 | 124 | switch (rc) {
|
126 | 125 | case EACCES:
|
127 | 126 | std::cout << "an attempt was made to write in a ";
|
@@ -494,22 +493,40 @@ void LMDB::resolveMultiMatches(const std::string& var,
|
494 | 493 | }
|
495 | 494 |
|
496 | 495 | while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) {
|
497 |
| - if (key.mv_size <= keySize + 1) { |
498 |
| - continue; |
499 |
| - } |
| 496 | + // |
| 497 | + // I don't see what's the reason of this clause |
| 498 | + // |
| 499 | + // eg: |
| 500 | + // looking for the variable: 'test', keySize will 4 |
| 501 | + // found key: 'test', key.mv_size will 4 |
| 502 | + // key.mv_size IS LESS than keySize+1, so we will continue? |
| 503 | + // |
| 504 | + //if (key.mv_size <= keySize + 1) { |
| 505 | + // continue; |
| 506 | + //} |
500 | 507 | char *a = reinterpret_cast<char *>(key.mv_data);
|
501 |
| - if (a[keySize] != ':') { |
502 |
| - continue; |
503 |
| - } |
| 508 | + // |
| 509 | + // also don't understand this part |
| 510 | + // |
| 511 | + // key.mv_data will 'test', but there isn't ':' at the end, |
| 512 | + // so we will skip it? |
| 513 | + // |
| 514 | + //if (a[keySize] != ':') { |
| 515 | + // continue; |
| 516 | + //} |
| 517 | + |
| 518 | + // this will never evaluate with the two statements above, |
| 519 | + // but I think this is the only required check |
504 | 520 | if (strncmp(var.c_str(), a, keySize) != 0) {
|
505 | 521 | continue;
|
506 | 522 | }
|
507 |
| - VariableValue *v = new VariableValue( |
508 |
| - new std::string(reinterpret_cast<char *>(key.mv_data), |
| 523 | + l->insert(l->begin(), new VariableValue( |
| 524 | + &m_name, |
| 525 | + new std::string(reinterpret_cast<char *>(key.mv_data), |
509 | 526 | key.mv_size),
|
510 |
| - new std::string(reinterpret_cast<char *>(data.mv_data), |
511 |
| - data.mv_size)); |
512 |
| - l->insert(l->begin(), v); |
| 527 | + new std::string(reinterpret_cast<char *>(data.mv_data), |
| 528 | + data.mv_size)) |
| 529 | + ); |
513 | 530 | }
|
514 | 531 |
|
515 | 532 | mdb_cursor_close(cursor);
|
|
0 commit comments