Description: fix denial of service and possible code execution via seeding manager reporter with crafted data Origin: upstream, http://www.squid-cache.org/Versions/v3/3.5/changesets/SQUID-2016_5.patch Index: squid3-3.5.12/src/tests/stub_cbdata.cc =================================================================== --- squid3-3.5.12.orig/src/tests/stub_cbdata.cc 2015-12-02 13:10:29.000000000 -0500 +++ squid3-3.5.12/src/tests/stub_cbdata.cc 2016-06-07 08:07:18.242973870 -0400 @@ -13,7 +13,13 @@ #include "tests/STUB.h" void cbdataRegisterWithCacheManager(void) STUB - +void *cbdataInternalAlloc(cbdata_type type, const char *, int sz) { + return xcalloc(1, sz); +} +void *cbdataInternalFree(void *p, const char *, int) { + xfree(p); + return NULL; +} #if USE_CBDATA_DEBUG void *cbdataInternalAllocDbg(cbdata_type type, const char *, int) STUB_RETVAL(NULL) void *cbdataInternalFreeDbg(void *p, const char *, int) STUB_RETVAL(NULL) Index: squid3-3.5.12/src/tests/stub_mem.cc =================================================================== --- squid3-3.5.12.orig/src/tests/stub_mem.cc 2015-12-02 13:10:29.000000000 -0500 +++ squid3-3.5.12/src/tests/stub_mem.cc 2016-06-07 08:07:18.242973870 -0400 @@ -14,7 +14,7 @@ #define STUB_API "stub_mem.cc" #include "Mem.h" -#include "STUB.h" +#include "tests/STUB.h" void memFreeString(size_t size, void *buf) Index: squid3-3.5.12/tools/Makefile.am =================================================================== --- squid3-3.5.12.orig/tools/Makefile.am 2015-12-02 13:10:29.000000000 -0500 +++ squid3-3.5.12/tools/Makefile.am 2016-06-07 08:07:18.242973870 -0400 @@ -34,15 +34,24 @@ stub_debug.cc: $(top_srcdir)/src/tests/stub_debug.cc cp $(top_srcdir)/src/tests/stub_debug.cc . +MemBuf.cc: $(top_srcdir)/src/MemBuf.cc + cp $(top_srcdir)/src/MemBuf.cc $@ + time.cc: $(top_srcdir)/src/time.cc cp $(top_srcdir)/src/time.cc . +stub_cbdata.cc: $(top_srcdir)/src/tests/stub_cbdata.cc + cp $(top_srcdir)/src/tests/stub_cbdata.cc $@ + +stub_mem.cc: $(top_srcdir)/src/tests/stub_mem.cc + cp $(top_srcdir)/src/tests/stub_mem.cc $@ + # stock tools for unit tests - library independent versions of dlink_list # etc. # globals.cc is needed by test_tools.cc. # Neither of these should be disted from here. TESTSOURCES= test_tools.cc -CLEANFILES += test_tools.cc stub_debug.cc time.cc +CLEANFILES += test_tools.cc MemBuf.cc stub_debug.cc time.cc stub_cbdata.cc stub_mem.cc ## ##### helper-mux ##### @@ -60,7 +69,10 @@ libexec_PROGRAMS = cachemgr$(CGIEXT) cachemgr__CGIEXT__SOURCES = cachemgr.cc \ + MemBuf.cc \ + stub_cbdata.cc \ stub_debug.cc \ + stub_mem.cc \ test_tools.cc \ time.cc Index: squid3-3.5.12/tools/cachemgr.cc =================================================================== --- squid3-3.5.12.orig/tools/cachemgr.cc 2015-12-02 13:10:29.000000000 -0500 +++ squid3-3.5.12/tools/cachemgr.cc 2016-06-07 08:07:18.242973870 -0400 @@ -11,6 +11,7 @@ #include "getfullhostname.h" #include "html_quote.h" #include "ip/Address.h" +#include "MemBuf.h" #include "rfc1123.h" #include "rfc1738.h" #include "util.h" @@ -423,8 +424,8 @@ return url; } -static const char * -munge_menu_line(const char *buf, cachemgr_request * req) +static void +munge_menu_line(MemBuf &out, const char *buf, cachemgr_request * req) { char *x; const char *a; @@ -432,15 +433,14 @@ const char *p; char *a_url; char *buf_copy; - static char html[2 * 1024]; - - if (strlen(buf) < 1) - return buf; - if (*buf != ' ') - return buf; + const char bufLen = strlen(buf); + if (bufLen < 1 || *buf != ' ') { + out.append(buf, bufLen); + return; + } - buf_copy = x = xstrdup(buf); + buf_copy = x = xstrndup(buf, bufLen); a = xstrtok(&x, '\t'); @@ -452,59 +452,56 @@ /* no reason to give a url for a disabled action */ if (!strcmp(p, "disabled")) - snprintf(html, sizeof(html), "
" : "", html_quote(buf)); + if (table_line_num) + out.append("\n", 14); + out.Printf("%s", html_quote(buf)); table_line_num = 0; - return html; + return; } /* start html table */ if (!table_line_num) { - l += snprintf(html + l, sizeof(html) - l, "