Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ec0a3a

Browse files
committed
Revise some macro in persist_dbm.c
1 parent950451a commit0ec0a3a

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

‎apache2/ag_mdb/ag_mdb_external.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
extern"C" {
66
#endif
77

8+
/**
9+
**========================================================
10+
** AG Memory Database Limitation Definition
11+
**========================================================
12+
*/
13+
#defineAGMDB_MAX_ENTRY_SIZE 1024
14+
15+
16+
817
/**
918
**========================================================
1019
** AG Memory Database Status Definition

‎apache2/ag_mdb/ag_mdb_internal.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ typedef unsigned long long PTR_OFFSET;
137137
#defineSHM_ENTRIES(base) ((PTR_VOID ) (base + SHM_ENTRIES_OFFSET))
138138

139139
/* SHM Default Setting */
140-
#defineDEFAULT_ENTRY_SIZE1024 // default size of each entry (1024B)
140+
#defineDEFAULT_ENTRY_SIZEAGMDB_MAX_ENTRY_SIZE // default size of each entry (1024B)
141141
#defineMAX_KEY_SIZE 128 // maximum key length (128B)
142142

143143
#defineDEFAULT_SHM_SIZE 0x40000000 // the default size of database (256MB)

‎apache2/persist_dbm.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
#include"modsecurity.h"
2121
#include"string.h"
2222
#include"stdio.h"
23-
//buffer temp define here, should use malloc latter
24-
#defineMAX_BUF_LEN 1024
25-
#defineDEFAULT_AGMDB_ENTRY_NUM 200000
2623

2724
//debug code
2825
#include<stdio.h>
@@ -135,7 +132,7 @@ static apr_table_t *collection_retrieve_ex(int db_option, void *existing_dbm, mo
135132

136133
//variables used for ag_dbm
137134
structagmdb_handler*ag_dbm=NULL;
138-
charbuffer[MAX_BUF_LEN];
135+
charbuffer[AGMDB_MAX_ENTRY_SIZE];
139136

140137
//variables used for apr_sdbm
141138
structapr_sdbm_t*apr_dbm=NULL;
@@ -225,7 +222,7 @@ static apr_table_t *collection_retrieve_ex(int db_option, void *existing_dbm, mo
225222
gotocleanup;
226223
}
227224
}
228-
rc2=AGMDB_get(ag_dbm,col_key,col_key_len,buffer,MAX_BUF_LEN);
225+
rc2=AGMDB_get(ag_dbm,col_key,col_key_len,buffer,AGMDB_MAX_ENTRY_SIZE);
229226
if (rc2==AGMDB_FAIL) {
230227
msr_log(msr,1,"[ERROR]collection_retrieve_ex_agmdb: Failed to read from database \"%s\": %s",log_escape(msr->mp,
231228
col_name),col_key);
@@ -608,7 +605,7 @@ static int collection_store_ex(int db_option, modsec_rec *msr, apr_table_t *col)
608605
new_handle->handle=apr_pcalloc(root_dcfg->mp,sizeof(structagmdb_handler));
609606
strcpy((char*)(new_handle->col_name),var_name->value);
610607

611-
rc=AGMDB_openDB(new_handle->handle,dbm_filename,strlen(dbm_filename),DEFAULT_AGMDB_ENTRY_NUM);
608+
rc=AGMDB_openDB(new_handle->handle,dbm_filename,strlen(dbm_filename),MAXIMUM_AGMDB_ENTRY_NUM);
612609
if(rc==AGMDB_FAIL){
613610
msr_log(msr,1,"[ERROR]collection_retrieve_ex_agmdb: Failed to create DBM name: %s",apr_psprintf(msr->mp,"%.*s",var_name->value_len,var_name->value));
614611
gotoerror;

‎apache2/persist_dbm.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@
1818
#include"apr_general.h"
1919
#include"modsecurity.h"
2020

21+
/* The DB Option Definition */
2122
#defineDB_OPT_AGMDB 1
2223
#defineDB_OPT_ORIGIN 0
24+
25+
/*
26+
* The maximum number of entries that database can support.
27+
* The database will refuse the new entry injection if the total entry number is larger than MAXIMUM_AGMDB_ENTRY_NUM
28+
* TODO: add as a configuration parameter
29+
*/
30+
#defineMAXIMUM_AGMDB_ENTRY_NUM 200000
31+
2332
structagmdb_handle_entry{
2433
constchar*col_name;
2534
void*handle;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp