]> granicus.if.org Git - apache/blobdiff - modules/filters/mod_include.c
Fix a segfault in mod_include when the original request has no
[apache] / modules / filters / mod_include.c
index 6ac346bd25d42c83d90658f24815a3346e3ae380..b65a50ba10d1c576b664610ebcdf4c55fc63d4f0 100644 (file)
@@ -182,6 +182,8 @@ static apr_bucket *find_start_sequence(apr_bucket *dptr, include_ctx_t *ctx,
                 if (ctx->head_start_index > 0) {
                     ctx->head_start_index  = 0;
                     ctx->head_start_bucket = tmp_bkt;
+                    ctx->parse_pos = 0;
+                    ctx->state = PRE_HEAD;
                 }
 
                 return tmp_bkt;
@@ -270,8 +272,11 @@ static apr_bucket *find_end_sequence(apr_bucket *dptr, include_ctx_t *ctx, apr_b
         }
         while (c < buf + len) {
             if (ctx->bytes_parsed >= BYTE_COUNT_THRESHOLD) {
-                /* gonna start over parsing the directive next time through */
-                ctx->directive_length = 0;
+                if (ctx->state == PARSE_DIRECTIVE) {
+                    /* gonna start over parsing the directive next time through */
+                    ctx->directive_length = 0;
+                    ctx->tag_length       = 0;
+                }
                 return dptr;
             }
 
@@ -827,8 +832,8 @@ static int handle_include(include_ctx_t *ctx, apr_bucket_brigade **bb, request_r
                     for (p = r; p != NULL && !founddupe; p = p->main) {
                    request_rec *q;
                    for (q = p; q != NULL; q = q->prev) {
-                       if ( (strcmp(q->filename, rr->filename) == 0) ||
-                            (strcmp(q->uri, rr->uri) == 0) ){
+                       if ((q->filename && rr->filename && (strcmp(q->filename, rr->filename) == 0)) ||
+                            (strcmp(q->uri, rr->uri) == 0){
                            founddupe = 1;
                            break;
                        }