I recently ran into an issue where Squid 2.7 would segfault trying to
issue HTCP CLR requests. I found the segfault only occurred on 64-bit
machines. While debugging, I found that the value of stuff.S.req_hdrs
was not initialized but later, strlen was being called on it. This
seems to -- by chance -- not fail on 32 bit builds, but always segfaults
on 64-bit. The attached patch fixed the problem for me and it seems
good programming practice to properly initialize pointers to prevent
issues such as this. As the htcpStuff struct is used in other places, I
have concerns that other issues may be lurking as well, although I have
yet to run into them.
Regards,
Jason
diff --git a/src/htcp.c b/src/htcp.c
index b262d0f..5cfe715 100644
--- a/src/htcp.c
+++ b/src/htcp.c
@@ -1265,6 +1265,7 @@ htcpClear(StoreEntry * e, const char *uri, request_t * req
stuff.f1 = 0;
stuff.response = 0;
stuff.msg_id = ++msg_id_counter;
+ stuff.S.req_hdrs = 0;
switch (reason) {
case HTCP_CLR_INVALIDATION:
stuff.reason = 1;