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

Commit063dd64

Browse files
author
Felipe Zimmerle
committed
Adds internal error messages while parsing the configutarion
Before this patch, if something went wrong while loading the configuration inmemory, not in terms of syntax but other run time factors such as memoryallocation, the webserver will refuse to start and no further message was givento the user. This patch adds "Internal Error messages" that are intend to letthe user know more information about the problem that he/she is facing.
1 parentda2ec00 commit063dd64

File tree

1 file changed

+72
-11
lines changed

1 file changed

+72
-11
lines changed

‎apache2/re.c‎

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -780,21 +780,49 @@ static apr_status_t msre_parse_actions(msre_engine *engine, msre_actionset *acti
780780
msre_action*action;
781781
inti;
782782

783-
if (text==NULL)return-1;
783+
784+
if (error_msg==NULL) {
785+
return-1;
786+
}
787+
*error_msg=NULL;
788+
789+
790+
if (text==NULL) {
791+
*error_msg=apr_psprintf(engine->mp,"Internal error: " \
792+
"msre_parse_actions, variable text is NULL");
793+
return-1;
794+
}
784795

785796
/* Extract name & value pairs first */
786797
vartable=apr_table_make(engine->mp,10);
787-
if (vartable==NULL)return-1;
798+
if (vartable==NULL) {
799+
*error_msg=apr_psprintf(engine->mp,"Internal error: " \
800+
"msre_parse_actions, failed to create vartable");
801+
802+
return-1;
803+
}
788804
rc=msre_parse_generic(engine->mp,text,vartable,error_msg);
789-
if (rc<0)returnrc;
805+
if (rc<0) {
806+
if (*error_msg==NULL)
807+
*error_msg=apr_psprintf(engine->mp,"Internal error: " \
808+
"msre_parse_actions, msre_parse_generic failed. Return " \
809+
"code: %d",rc);
810+
811+
returnrc;
812+
}
790813

791814
/* Loop through the table and create actions */
792815
tarr=apr_table_elts(vartable);
793816
telts= (constapr_table_entry_t*)tarr->elts;
794817
for (i=0;i<tarr->nelts;i++) {
795818
/* Create action. */
796819
action=msre_create_action(engine,telts[i].key,telts[i].val,error_msg);
797-
if (action==NULL)return-1;
820+
if (action==NULL) {
821+
if (*error_msg==NULL)
822+
*error_msg=apr_psprintf(engine->mp,"Internal error: " \
823+
"msre_parse_actions, msre_create_action failed.");
824+
return-1;
825+
}
798826

799827
/* Initialise action (option). */
800828
if (action->metadata->init!=NULL) {
@@ -932,12 +960,23 @@ static msre_var *msre_create_var(msre_ruleset *ruleset, const char *name, const
932960
msre_action*msre_create_action(msre_engine*engine,constchar*name,constchar*param,
933961
char**error_msg)
934962
{
935-
msre_action*action=apr_pcalloc(engine->mp,sizeof(msre_action));
936-
if (action==NULL)returnNULL;
963+
msre_action*action=NULL;
937964

938-
if (error_msg==NULL)returnNULL;
965+
if (error_msg==NULL) {
966+
returnNULL;
967+
}
939968
*error_msg=NULL;
940969

970+
971+
action=apr_pcalloc(engine->mp,sizeof(msre_action));
972+
973+
if (action==NULL) {
974+
*error_msg=apr_psprintf(engine->mp,"Internal error: " \
975+
"msre_create_action, not able to allocate action");
976+
977+
returnNULL;
978+
}
979+
941980
/* Resolve action */
942981
action->metadata=msre_resolve_action(engine,name);
943982
if (action->metadata==NULL) {
@@ -1128,12 +1167,29 @@ int msre_parse_generic(apr_pool_t *mp, const char *text, apr_table_t *vartable,
11281167
msre_actionset*msre_actionset_create(msre_engine*engine,constchar*text,
11291168
char**error_msg)
11301169
{
1131-
msre_actionset*actionset= (msre_actionset*)apr_pcalloc(engine->mp,
1170+
msre_actionset*actionset=NULL;
1171+
1172+
if (error_msg==NULL) {
1173+
returnNULL;
1174+
}
1175+
1176+
*error_msg=NULL;
1177+
1178+
actionset= (msre_actionset*)apr_pcalloc(engine->mp,
11321179
sizeof(msre_actionset));
1133-
if (actionset==NULL)returnNULL;
1180+
1181+
if (actionset==NULL) {
1182+
*error_msg=apr_psprintf(engine->mp,"Internal error: " \
1183+
"msre_actionset_create, not able to allocate msre_actionset");
1184+
returnNULL;
1185+
}
11341186

11351187
actionset->actions=apr_table_make(engine->mp,25);
1136-
if (actionset->actions==NULL)returnNULL;
1188+
if (actionset->actions==NULL) {
1189+
*error_msg=apr_psprintf(engine->mp,"Internal error: " \
1190+
"msre_actionset_create, not able to create actions table");
1191+
returnNULL;
1192+
}
11371193

11381194
/* Metadata */
11391195
actionset->id=NOT_SET_P;
@@ -1169,7 +1225,12 @@ msre_actionset *msre_actionset_create(msre_engine *engine, const char *text,
11691225

11701226
/* Parse the list of actions, if it's present */
11711227
if (text!=NULL) {
1172-
if (msre_parse_actions(engine,actionset,text,error_msg)<0) {
1228+
intret=msre_parse_actions(engine,actionset,text,error_msg);
1229+
if (ret<0) {
1230+
if (*error_msg==NULL)
1231+
*error_msg=apr_psprintf(engine->mp,"Internal error: " \
1232+
"msre_actionset_create, msre_parse_actions failed " \
1233+
"without further information. Return code: %d",ret);
11731234
returnNULL;
11741235
}
11751236
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp