1 ------------------------------------------------------------
3 revision-id: squid3@treenet.co.nz-20170622153146-nxo8vl6a9r8z03v4
4 parent: squid3@treenet.co.nz-20170621201248-ezpvykg0b307ix61
5 fixes bug: http://bugs.squid-cache.org/show_bug.cgi?id=4671
6 committer: Amos Jeffries <squid3@treenet.co.nz>
8 timestamp: Fri 2017-06-23 03:31:46 +1200
10 Bug 4671 pt3: various GCC 7 compile errors
12 Also, remove limit on FTP realm strings
14 Convert ftpRealm() from generating char* to SBuf. This fixes issues identified
15 by GCC 7 where the realm string may be longer than the available buffer and
17 The size of the buffer was making the occurance rather rare, but it is still
19 ------------------------------------------------------------
20 # Bazaar merge directive format 2 (Bazaar 0.90)
21 # revision_id: squid3@treenet.co.nz-20170622153146-nxo8vl6a9r8z03v4
22 # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5
23 # testament_sha1: b54e1a339544443ed9b34a094717b2781c746c76
24 # timestamp: 2017-06-22 15:50:59 +0000
25 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5
26 # base_revision_id: squid3@treenet.co.nz-20170621201248-\
30 === modified file 'src/DiskIO/DiskThreads/aiops.cc'
31 --- src/DiskIO/DiskThreads/aiops.cc 2017-01-01 00:16:45 +0000
32 +++ src/DiskIO/DiskThreads/aiops.cc 2017-06-22 15:31:46 +0000
34 /* Create threads and get them to sit in their wait loop */
35 squidaio_thread_pool = memPoolCreate("aio_thread", sizeof(squidaio_thread_t));
38 + assert(NUMTHREADS != 0);
40 for (i = 0; i < NUMTHREADS; ++i) {
41 threadp = (squidaio_thread_t *)squidaio_thread_pool->alloc();
43 === modified file 'src/clients/FtpGateway.cc'
44 --- src/clients/FtpGateway.cc 2017-06-21 19:54:39 +0000
45 +++ src/clients/FtpGateway.cc 2017-06-22 15:31:46 +0000
47 virtual void timeout(const CommTimeoutCbParams &io);
48 void ftpAcceptDataConnection(const CommAcceptCbParams &io);
50 - static HttpReply *ftpAuthRequired(HttpRequest * request, const char *realm);
51 - const char *ftpRealm(void);
52 + static HttpReply *ftpAuthRequired(HttpRequest * request, SBuf &realm);
54 void loginFailed(void);
56 virtual void haveParsedReplyHeaders();
59 if (!checkAuth(&request->header)) {
60 /* create appropriate reply */
61 - HttpReply *reply = ftpAuthRequired(request, ftpRealm());
62 + SBuf realm(ftpRealm()); // local copy so SBuf wont disappear too early
63 + HttpReply *reply = ftpAuthRequired(request, realm);
64 entry->replaceHttpReply(reply);
69 #if HAVE_AUTH_MODULE_BASIC
70 /* add Authenticate header */
71 - newrep->header.putAuth("Basic", ftpRealm());
72 + // XXX: performance regression. c_str() may reallocate
73 + SBuf realm(ftpRealm()); // local copy so SBuf wont disappear too early
74 + newrep->header.putAuth("Basic", realm.c_str());
77 // add it to the store entry for response....
78 @@ -1298,18 +1301,19 @@
84 Ftp::Gateway::ftpRealm()
86 - static char realm[8192];
89 /* This request is not fully authenticated */
91 - snprintf(realm, 8192, "FTP %s unknown", user);
92 - } else if (request->port == 21) {
93 - snprintf(realm, 8192, "FTP %s %s", user, request->GetHost());
95 - snprintf(realm, 8192, "FTP %s %s port %d", user, request->GetHost(), request->port);
96 + realm.appendf("FTP %s ", user);
98 + realm.append("unknown", 7);
100 + realm.append(request->GetHost());
101 + if (request->port != 21)
102 + realm.appendf(" port %d", request->port);
106 @@ -2673,13 +2677,14 @@
110 -Ftp::Gateway::ftpAuthRequired(HttpRequest * request, const char *realm)
111 +Ftp::Gateway::ftpAuthRequired(HttpRequest * request, SBuf &realm)
113 ErrorState err(ERR_CACHE_ACCESS_DENIED, Http::scUnauthorized, request);
114 HttpReply *newrep = err.BuildHttpReply();
115 #if HAVE_AUTH_MODULE_BASIC
116 /* add Authenticate header */
117 - newrep->header.putAuth("Basic", realm);
118 + // XXX: performance regression. c_str() may reallocate
119 + newrep->header.putAuth("Basic", realm.c_str());
124 === modified file 'src/fde.cc'
125 --- src/fde.cc 2017-01-01 00:16:45 +0000
126 +++ src/fde.cc 2017-06-22 15:31:46 +0000
129 fde::remoteAddr() const
131 - LOCAL_ARRAY(char, buf, MAX_IPSTRLEN );
132 + static char buf[MAX_IPSTRLEN+7]; // 7 = length of ':port' strings
134 if (type != FD_SOCKET)
138 - snprintf( buf, MAX_IPSTRLEN, "%s:%d", ipaddr, (int)remote_port);
139 + snprintf(buf, sizeof(buf), "%s:%u", ipaddr, remote_port);
141 - local_addr.toUrl(buf,MAX_IPSTRLEN); // toHostStr does not include port.
142 + local_addr.toUrl(buf, sizeof(buf)); // toHostStr does not include port.
147 === modified file 'src/fs/ufs/RebuildState.cc'
148 --- src/fs/ufs/RebuildState.cc 2017-01-01 00:16:45 +0000
149 +++ src/fs/ufs/RebuildState.cc 2017-06-22 15:31:46 +0000
153 if (0 == in_dir) { /* we need to read in a new directory */
154 - snprintf(fullpath, MAXPATHLEN, "%s/%02X/%02X",
155 + snprintf(fullpath, sizeof(fullpath), "%s/%02X/%02X",
163 - snprintf(fullfilename, MAXPATHLEN, "%s/%s",
164 + snprintf(fullfilename, sizeof(fullfilename), "%s/%s",
165 fullpath, entry->d_name);
166 debugs(47, 3, HERE << "Opening " << fullfilename);
167 fd = file_open(fullfilename, O_RDONLY | O_BINARY);
169 === modified file 'src/fs/ufs/RebuildState.h'
170 --- src/fs/ufs/RebuildState.h 2017-01-01 00:16:45 +0000
171 +++ src/fs/ufs/RebuildState.h 2017-06-22 15:31:46 +0000
175 char fullpath[MAXPATHLEN];
176 - char fullfilename[MAXPATHLEN];
177 + char fullfilename[MAXPATHLEN*2];
179 StoreRebuildData counts;
182 === modified file 'src/gopher.cc'
183 --- src/gopher.cc 2017-01-01 00:16:45 +0000
184 +++ src/gopher.cc 2017-06-22 15:31:46 +0000
186 * This will be called when request write is complete. Schedule read of reply.
189 -gopherSendComplete(const Comm::ConnectionPointer &conn, char *buf, size_t size, Comm::Flag errflag, int xerrno, void *data)
190 +gopherSendComplete(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag errflag, int xerrno, void *data)
192 GopherStateData *gopherState = (GopherStateData *) data;
193 StoreEntry *entry = gopherState->entry;
195 err->url = xstrdup(entry->url());
196 gopherState->fwd->fail(err);
197 gopherState->serverConn->close();
200 - memFree(buf, MEM_4K_BUF); /* Allocated by gopherSendRequest. */
206 AsyncCall::Pointer call = commCbCall(5,5, "gopherReadReply",
207 CommIoCbPtrFun(gopherReadReply, gopherState));
208 entry->delayAwareRead(conn, gopherState->replybuf, BUFSIZ, call);
211 - memFree(buf, MEM_4K_BUF); /* Allocated by gopherSendRequest. */
215 @@ -898,32 +891,31 @@
216 gopherSendRequest(int fd, void *data)
218 GopherStateData *gopherState = (GopherStateData *)data;
219 - char *buf = (char *)memAllocate(MEM_4K_BUF);
223 if (gopherState->type_id == GOPHER_CSO) {
224 const char *t = strchr(gopherState->request, '?');
228 ++t; /* skip the ? */
232 - snprintf(buf, 4096, "query %s\r\nquit\r\n", t);
233 - } else if (gopherState->type_id == GOPHER_INDEX) {
234 - char *t = strchr(gopherState->request, '?');
239 - snprintf(buf, 4096, "%s\r\n", gopherState->request);
240 + mb.Printf("query %s\r\nquit", t);
242 - snprintf(buf, 4096, "%s\r\n", gopherState->request);
243 + if (gopherState->type_id == GOPHER_INDEX) {
244 + if (char *t = strchr(gopherState->request, '?'))
247 + mb.append(gopherState->request, strlen(gopherState->request));
249 + mb.append("\r\n", 2);
251 - debugs(10, 5, HERE << gopherState->serverConn);
252 + debugs(10, 5, gopherState->serverConn);
253 AsyncCall::Pointer call = commCbCall(5,5, "gopherSendComplete",
254 CommIoCbPtrFun(gopherSendComplete, gopherState));
255 - Comm::Write(gopherState->serverConn, buf, strlen(buf), call, NULL);
256 + Comm::Write(gopherState->serverConn, &mb, call);
258 gopherState->entry->makePublic();
261 === modified file 'src/icmp/Makefile.am'
262 --- src/icmp/Makefile.am 2017-01-01 00:16:45 +0000
263 +++ src/icmp/Makefile.am 2017-06-22 15:31:46 +0000
265 pinger_LDFLAGS = $(LIBADD_DL)
269 + $(top_builddir)/src/ip/libip.la \
270 + $(top_builddir)/src/base/libbase.la \