Skip to content

Commit 23181c0

Browse files
committed
avoid infinite loop when header not found
1 parent eacbe93 commit 23181c0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/http.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ size_t _mapcache_curl_header_callback( void *ptr, size_t size, size_t nmemb, vo
7777
static void _header_replace_str(mapcache_context *ctx, apr_table_t *headers, char **val) {
7878
char *value = *val;
7979
char *start_tag, *end_tag;
80+
size_t start_tag_offset;
8081
start_tag = strchr(value,'{');
8182
while(start_tag) {
83+
start_tag_offset = start_tag - value; /*record where we found the '{' so we can look for the next one after that spot
84+
(avoids infinite loop if tag was not found/replaced) */
8285
*start_tag=0;
8386
end_tag = strchr(start_tag+1,'}');
8487
if(end_tag) {
@@ -91,7 +94,7 @@ static void _header_replace_str(mapcache_context *ctx, apr_table_t *headers, cha
9194
*end_tag='}';
9295
}
9396
*start_tag='{';
94-
start_tag = strchr(value,'{');
97+
start_tag = strchr(value+start_tag_offset+1,'{');
9598
}
9699
*val = value;
97100
}

0 commit comments

Comments
 (0)