Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
squid.3507
SQUID-2016_5.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File SQUID-2016_5.patch of Package squid.3507
------------------------------------------------------------ revno: 12695 revision-id: squid3@treenet.co.nz-20160420064259-k9dn77q0xna1doax parent: squid3@treenet.co.nz-20160330141606-19rqzzip0grq9a77 committer: Amos Jeffries <squid3@treenet.co.nz> branch nick: 3.3 timestamp: Wed 2016-04-20 18:42:59 +1200 message: cachemgr.cgi: use dynamic MemBuf for internal content generation Using a fixed size buffer limits how big content lines can be. Modern HTTP is fast reaching the point where such limits are problematic. Also fixes incorrect uses of snprintf() by removing them. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20160420064259-k9dn77q0xna1doax # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # testament_sha1: 0c7cd2d0ababe794c0fd5b1dc94c647c064c122d # timestamp: 2016-04-20 06:50:48 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # base_revision_id: squid3@treenet.co.nz-20160330141606-\ # 19rqzzip0grq9a77 # # Begin patch === modified file 'src/tests/Stub.list' --- src/tests/Stub.list 2014-10-08 15:31:39 +0000 +++ src/tests/Stub.list 2016-04-20 06:42:59 +0000 @@ -3,6 +3,7 @@ tests/stub_acl.cc \ tests/stub_cache_cf.cc \ tests/stub_cache_manager.cc \ + tests/stub_cbdata.cc \ tests/stub_client_db.cc \ tests/stub_client_side_request.cc \ tests/stub_comm.cc \ === added file 'src/tests/stub_cbdata.cc' --- src/tests/stub_cbdata.cc 1970-01-01 00:00:00 +0000 +++ src/tests/stub_cbdata.cc 2016-04-20 06:42:59 +0000 @@ -0,0 +1,30 @@ +#include "squid.h" +#include "cbdata.h" + +#define STUB_API "cbdata.cc" +#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 nullptr; +} +#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) +void cbdataInternalLockDbg(const void *p, const char *, int) STUB +void cbdataInternalUnlockDbg(const void *p, const char *, int) STUB +int cbdataInternalReferenceDoneValidDbg(void **p, void **tp, const char *, int) STUB_RETVAL(0) +#else +void *cbdataInternalAlloc(cbdata_type type) STUB_RETVAL(NULL) +void *cbdataInternalFree(void *p) STUB_RETVAL(NULL) +void cbdataInternalLock(const void *p) STUB +void cbdataInternalUnlock(const void *p) STUB +int cbdataInternalReferenceDoneValid(void **p, void **tp) STUB_RETVAL(0) +#endif + +int cbdataReferenceValid(const void *p) STUB_RETVAL(0) +cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, int size, FREE * free_func) STUB_RETVAL(CBDATA_UNKNOWN) === modified file 'src/tests/stub_mem.cc' --- src/tests/stub_mem.cc 2012-08-29 07:29:35 +0000 +++ src/tests/stub_mem.cc 2016-04-20 06:42:59 +0000 @@ -5,7 +5,7 @@ #include "squid.h" #define STUB_API "stub_mem.cc" -#include "STUB.h" +#include "tests/STUB.h" #include "Mem.h" void === modified file 'tools/Makefile.am' --- tools/Makefile.am 2010-12-06 14:06:06 +0000 +++ tools/Makefile.am 2016-04-20 06:42:59 +0000 @@ -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 ##### @@ -73,7 +82,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 === modified file 'tools/cachemgr.cc' --- tools/cachemgr.cc 2013-09-09 07:17:19 +0000 +++ tools/cachemgr.cc 2016-04-20 06:42:59 +0000 @@ -35,6 +35,7 @@ #include "getfullhostname.h" #include "html_quote.h" #include "ip/Address.h" +#include "MemBuf.h" #include "rfc1123.h" #include "rfc1738.h" #include "util.h" @@ -460,8 +461,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; @@ -469,15 +470,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; - - buf_copy = x = xstrdup(buf); + + const char bufLen = strlen(buf); + if (bufLen < 1 || *buf != ' ') { + out.append(buf, bufLen); + return; + } + + buf_copy = x = xstrndup(buf, bufLen); a = xstrtok(&x, '\t'); @@ -489,59 +489,56 @@ /* no reason to give a url for a disabled action */ if (!strcmp(p, "disabled")) - snprintf(html, sizeof(html), "<LI type=\"circle\">%s (disabled)<A HREF=\"%s\">.</A>\n", d, a_url); + out.Printf("<LI type=\"circle\">%s (disabled)<A HREF=\"%s\">.</A>\n", d, a_url); else /* disable a hidden action (requires a password, but password is not in squid.conf) */ if (!strcmp(p, "hidden")) - snprintf(html, sizeof(html), "<LI type=\"circle\">%s (hidden)<A HREF=\"%s\">.</A>\n", d, a_url); + out.Printf("<LI type=\"circle\">%s (hidden)<A HREF=\"%s\">.</A>\n", d, a_url); else /* disable link if authentication is required and we have no password */ if (!strcmp(p, "protected") && !req->passwd) - snprintf(html, sizeof(html), "<LI type=\"circle\">%s (requires <a href=\"%s\">authentication</a>)<A HREF=\"%s\">.</A>\n", - d, menu_url(req, "authenticate"), a_url); + out.Printf("<LI type=\"circle\">%s (requires <a href=\"%s\">authentication</a>)<A HREF=\"%s\">.</A>\n", + d, menu_url(req, "authenticate"), a_url); else /* highlight protected but probably available entries */ if (!strcmp(p, "protected")) - snprintf(html, sizeof(html), "<LI type=\"square\"><A HREF=\"%s\"><font color=\"#FF0000\">%s</font></A>\n", - a_url, d); + out.Printf("<LI type=\"square\"><A HREF=\"%s\"><font color=\"#FF0000\">%s</font></A>\n", + a_url, d); /* public entry or unknown type of protection */ else - snprintf(html, sizeof(html), "<LI type=\"disk\"><A HREF=\"%s\">%s</A>\n", a_url, d); + out.Printf("<LI type=\"disk\"><A HREF=\"%s\">%s</A>\n", a_url, d); xfree(a_url); xfree(buf_copy); - - return html; } -static const char * -munge_other_line(const char *buf, cachemgr_request * req) +static void +munge_other_line(MemBuf &out, const char *buf, cachemgr_request *) { static const char *ttags[] = {"td", "th"}; - static char html[4096]; static int table_line_num = 0; static int next_is_header = 0; int is_header = 0; const char *ttag; char *buf_copy; char *x, *p; - int l = 0; /* does it look like a table? */ if (!strchr(buf, '\t') || *buf == '\t') { /* nope, just text */ - snprintf(html, sizeof(html), "%s%s", - table_line_num ? "</table>\n<pre>" : "", html_quote(buf)); + if (table_line_num) + out.append("</table>\n<pre>", 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, "</pre><table cellpadding=\"2\" cellspacing=\"1\">\n"); + out.append("</pre><table cellpadding=\"2\" cellspacing=\"1\">\n", 46); next_is_header = 0; } @@ -551,7 +548,7 @@ ttag = ttags[is_header]; /* record starts */ - l += snprintf(html + l, sizeof(html) - l, "<tr>"); + out.append("<tr>", 4); /* substitute '\t' */ buf_copy = x = xstrdup(buf); @@ -568,18 +565,17 @@ ++x; } - l += snprintf(html + l, sizeof(html) - l, "<%s colspan=\"%d\" align=\"%s\">%s</%s>", - ttag, column_span, - is_header ? "center" : is_number(cell) ? "right" : "left", - html_quote(cell), ttag); + out.Printf("<%s colspan=\"%d\" align=\"%s\">%s</%s>", + ttag, column_span, + is_header ? "center" : is_number(cell) ? "right" : "left", + html_quote(cell), ttag); } xfree(buf_copy); /* record ends */ - snprintf(html + l, sizeof(html) - l, "</tr>\n"); + out.append("</tr>\n", 6); next_is_header = is_header && strstr(buf, "\t\t"); ++table_line_num; - return html; } static const char * @@ -736,14 +732,18 @@ /* yes, fall through, we do not want to loose the first line */ case isBody: + { /* interpret [and reformat] cache response */ - + MemBuf out; + out.init(); if (parse_menu) - fputs(munge_menu_line(buf, req), stdout); + munge_menu_line(out, buf, req); else - fputs(munge_other_line(buf, req), stdout); + munge_other_line(out, buf, req); - break; + fputs(out.buf, stdout); + } + break; case isForward: /* forward: no modifications allowed */ ------------------------------------------------------------ revno: 12696 revision-id: squid3@treenet.co.nz-20160420101500-nm50i4u3iftemzs6 parent: squid3@treenet.co.nz-20160420064259-k9dn77q0xna1doax committer: Amos Jeffries <squid3@treenet.co.nz> branch nick: 3.3 timestamp: Wed 2016-04-20 22:15:00 +1200 message: nullptr is a C++11 feature ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20160420101500-nm50i4u3iftemzs6 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # testament_sha1: 091f2aa4b835390972c0f42e67128484d653c2ee # timestamp: 2016-04-20 10:50:54 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # base_revision_id: squid3@treenet.co.nz-20160420064259-\ # k9dn77q0xna1doax # # Begin patch === modified file 'src/tests/stub_cbdata.cc' --- src/tests/stub_cbdata.cc 2016-04-20 06:42:59 +0000 +++ src/tests/stub_cbdata.cc 2016-04-20 10:15:00 +0000 @@ -10,7 +10,7 @@ } void *cbdataInternalFree(void *p, const char *, int) { xfree(p); - return nullptr; + return NULL; } #if USE_CBDATA_DEBUG void *cbdataInternalAllocDbg(cbdata_type type, const char *, int) STUB_RETVAL(NULL)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor