strstr(url, urlpath) assertion in http.cc

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Thu, 12 Jan 2012 16:30:21 -0700

Hello,

    Long time ago, I hit the following strstr() assertion in http.cc
during rigorous Squid testing, possibly with malformed traffic:

> /* Add max-age only without no-cache */
> if (!EBIT_TEST(cc->mask, CC_MAX_AGE) && !EBIT_TEST(cc->mask, CC_NO_CACHE)) {
> const char *url =
> entry ? entry->url() : urlCanonical(orig_request);
> httpHdrCcSetMaxAge(cc, getMaxAge(url));
>
> if (request->urlpath.size())
> assert(strstr(url, request->urlpath.termedBuf()));
> }

I remember that I could not understand what that assertion is checking
and, especially, why a URL-related check is located inside a
Cache-Control: max-age clause. Since I was in a rush, and working on
branched code, I simply replaced the assertion with a debugging
statement and forgot about it. I personally never seen that debugging
statement in the logs but I cannot be 100% certain that it never
triggered in production.

I am working on closing that branch and found that this assertion is
still in Squid3 trunk. I would like to either remove the assertion in
trunk OR understand why the assertion is needed.

Could somebody tell me what that assertion does and why it is in that
specific place, please?

Thank you,

Alex.
Received on Thu Jan 12 2012 - 23:30:49 MST

This archive was generated by hypermail 2.2.0 : Mon Jan 16 2012 - 12:00:05 MST