Skip to content

Commit 6473cf6

Browse files
hideakiFelipe Zimmerle
authored andcommitted
Make url path absolute for SecHashEngine only when it is relative in the first place. Fix #752
1 parent 6f49bad commit 6473cf6

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

apache2/msc_crypt.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,30 @@ char *normalize_path(modsec_rec *msr, char *input) {
6868
char *Uri = NULL;
6969
int bytes = 0;
7070
/*int i;*/
71-
char *relative_link = NULL;
71+
char *abs_link = NULL;
7272
char *filename = NULL;
73-
char *relative_path = NULL;
74-
char *relative_uri = NULL;
73+
char *abs_path = NULL;
74+
char *abs_uri = NULL;
7575

76-
filename = file_basename(msr->mp, msr->r->parsed_uri.path);
76+
if (uri->path[0] != '/') {
77+
/* uri->path is relative. make it absolute */
78+
filename = file_basename(msr->mp, msr->r->parsed_uri.path);
7779

78-
if(filename == NULL || (strlen(msr->r->parsed_uri.path) - strlen(filename) < 0))
79-
return NULL;
80+
if(filename == NULL || (strlen(msr->r->parsed_uri.path) - strlen(filename) < 0))
81+
return NULL;
8082

81-
relative_path = apr_pstrndup(msr->mp, msr->r->parsed_uri.path, strlen(msr->r->parsed_uri.path) - strlen(filename));
82-
relative_uri = apr_pstrcat(msr->mp, relative_path, uri->path, NULL);
83+
abs_path = apr_pstrndup(msr->mp, msr->r->parsed_uri.path, strlen(msr->r->parsed_uri.path) - strlen(filename));
84+
abs_uri = apr_pstrcat(msr->mp, abs_path, uri->path, NULL);
8385

84-
relative_link = apr_pstrdup(msr->mp, relative_uri);
86+
abs_link = apr_pstrdup(msr->mp, abs_uri);
87+
}
88+
else {
89+
abs_link = apr_pstrdup(msr->mp, uri->path);
90+
}
8591

86-
xmlNormalizeURIPath(relative_link);
92+
xmlNormalizeURIPath(abs_link);
8793

88-
Uri = apr_pstrdup(msr->mp, relative_link);
94+
Uri = apr_pstrdup(msr->mp, abs_link);
8995

9096
/*
9197
for(i = 0; i < (int)strlen(Uri); i++) {

0 commit comments

Comments
 (0)