Commit b2d19c5f authored by Tollef Fog Heen's avatar Tollef Fog Heen

Use memchr rather than strchr/index

the strings we get from the libvarnishapi functions are not
necessarily null-terminated, so avoid using str* functions on them.

Thanks to lampe for the patch.

Fixes #1115
parent 1ebcb83a
......@@ -312,7 +312,7 @@ collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
clean_logline(lp);
break;
}
qs = index(ptr, '?');
qs = memchr(ptr, '?', len);
if (qs) {
lp->df_U = trimline(ptr, qs);
lp->df_q = trimline(qs, end);
......@@ -356,7 +356,7 @@ collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
case SLT_BereqHeader:
if (!lp->active)
break;
split = strchr(ptr, ':');
split = memchr(ptr, ':', len);
if (split == NULL)
break;
if (isprefix(ptr, "authorization:", end, &next) &&
......@@ -431,7 +431,7 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
clean_logline(lp);
break;
}
qs = index(ptr, '?');
qs = memchr(ptr, '?', len);
if (qs) {
lp->df_U = trimline(ptr, qs);
lp->df_q = trimline(qs, end);
......@@ -464,7 +464,7 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
case SLT_ReqHeader:
if (!lp->active)
break;
split = strchr(ptr, ':');
split = memchr(ptr, ':', len);
if (split == NULL)
break;
if (tag == SLT_ReqHeader &&
......@@ -490,7 +490,7 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
if(!lp->active)
break;
split = strchr(ptr, ':');
split = memchr(ptr, ':', len);
if (split == NULL)
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment