From: Alex Rousskov Date: Fri, 8 Aug 2014 03:07:03 +0000 (-0600) Subject: SourceFormat Enforcement X-Git-Tag: SQUID_3_5_0_1~117^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=27c841f6c5e57c71e94a3651034cdd67750a4527;p=thirdparty%2Fsquid.git SourceFormat Enforcement --- diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 0d7b2b7c8d..e9eef0f33b 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -739,9 +739,9 @@ HttpHeader::packInto(Packer * p, bool mask_sensitive_info) const e->packInto(p); continue; } - switch (e->id) { // TODO: When native FTP commands may end up in error pages and other // sensitive places, hide HDR_FTP_ARGUMENTS for the FTP PASS command. + switch (e->id) { case HDR_AUTHORIZATION: case HDR_PROXY_AUTHORIZATION: packerAppend(p, e->name.rawBuf(), e->name.size()); diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 1e37007ddc..17835cf12c 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -3753,9 +3753,9 @@ parse_port_option(AnyP::PortCfgPointer &s, char *token) parseBytesOptionValue(&s->dynamicCertMemCacheSize, B_BYTES_STR, token + 28); #endif } else if (strcmp(token, "ftp-track-dirs=on") == 0) { - s->ftp_track_dirs = true; + s->ftp_track_dirs = true; } else if (strcmp(token, "ftp-track-dirs=off") == 0) { - s->ftp_track_dirs = false; + s->ftp_track_dirs = false; } else { debugs(3, DBG_CRITICAL, "FATAL: Unknown http(s)_port option '" << token << "'."); self_destruct(); diff --git a/src/clientStream.h b/src/clientStream.h index 8cce69a1a5..2c3348b7e9 100644 --- a/src/clientStream.h +++ b/src/clientStream.h @@ -33,8 +33,8 @@ #define SQUID_CLIENTSTREAM_H #include "base/RefCount.h" -#include "dlink.h" #include "clientStreamForward.h" +#include "dlink.h" #include "StoreIOBuffer.h" /** diff --git a/src/client_side.cc b/src/client_side.cc index bd82eccfc2..28de880e8e 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -4111,7 +4111,8 @@ clientHttpsConnectionsOpen(void) #endif void -clientStartListeningOn(AnyP::PortCfgPointer &port, const RefCount< CommCbFunPtrCallT > &subCall, const Ipc::FdNoteId fdNote) { +clientStartListeningOn(AnyP::PortCfgPointer &port, const RefCount< CommCbFunPtrCallT > &subCall, const Ipc::FdNoteId fdNote) +{ // Fill out a Comm::Connection which IPC will open as a listener for us port->listenConn = new Comm::Connection; port->listenConn->local = port->s; @@ -4443,7 +4444,7 @@ void ConnStateData::pinConnection(const Comm::ConnectionPointer &pinServer, HttpRequest *request, CachePeer *aPeer, bool auth, bool monitor) { if (!Comm::IsConnOpen(pinning.serverConnection) || - pinning.serverConnection->fd != pinServer->fd) + pinning.serverConnection->fd != pinServer->fd) pinNewConnection(pinServer, request, aPeer, auth); if (monitor) diff --git a/src/clients/FtpClient.cc b/src/clients/FtpClient.cc index 0476a4a4db..f6a3132411 100644 --- a/src/clients/FtpClient.cc +++ b/src/clients/FtpClient.cc @@ -6,11 +6,8 @@ #include "squid.h" #include "acl/FilledChecklist.h" -#include "clients/FtpClient.h" -#include "Mem.h" -#include "SquidConfig.h" -#include "StatCounters.h" #include "client_side.h" +#include "clients/FtpClient.h" #include "comm/ConnOpener.h" #include "comm/Read.h" #include "comm/TcpAcceptor.h" @@ -19,12 +16,16 @@ #include "fd.h" #include "ftp/Parsing.h" #include "ip/tools.h" +#include "Mem.h" +#include "SquidConfig.h" #include "SquidString.h" +#include "StatCounters.h" #include "tools.h" #include "wordlist.h" #include -namespace Ftp { +namespace Ftp +{ const char *const crlf = "\r\n"; @@ -64,7 +65,7 @@ escapeIAC(const char *buf) /// configures the channel with a descriptor and registers a close handler void Ftp::Channel::opened(const Comm::ConnectionPointer &newConn, - const AsyncCall::Pointer &aCloser) + const AsyncCall::Pointer &aCloser) { assert(!Comm::IsConnOpen(conn)); assert(closer == NULL); @@ -147,11 +148,11 @@ Ftp::DataChannel::~DataChannel() void Ftp::DataChannel::addr(const Ip::Address &import) { - static char addrBuf[MAX_IPSTRLEN]; - import.toStr(addrBuf, sizeof(addrBuf)); - xfree(host); - host = xstrdup(addrBuf); - port = import.port(); + static char addrBuf[MAX_IPSTRLEN]; + import.toStr(addrBuf, sizeof(addrBuf)); + xfree(host); + host = xstrdup(addrBuf); + port = import.port(); } /* Ftp::Client */ @@ -173,7 +174,7 @@ Ftp::Client::Client(FwdState *fwdState): typedef CommCbMemFunT Dialer; const AsyncCall::Pointer closer = JobCallback(9, 5, Dialer, this, - Ftp::Client::ctrlClosed); + Ftp::Client::ctrlClosed); ctrl.opened(fwdState->serverConnection(), closer); } @@ -281,7 +282,7 @@ Ftp::Client::failedHttpStatus(err_type &error) if (error == ERR_NONE) error = ERR_FTP_FAILURE; return error == ERR_READ_TIMEOUT ? Http::scGatewayTimeout : - Http::scBadGateway; + Http::scBadGateway; } /** @@ -618,7 +619,6 @@ Ftp::Client::sendPassive() return false; } - /// Closes any old FTP-Data connection which may exist. */ data.close(); @@ -710,7 +710,6 @@ Ftp::Client::sendPassive() return true; } - void Ftp::Client::connectDataChannel() { @@ -1008,7 +1007,7 @@ Ftp::Client::switchTimeoutToDataChannel() typedef CommCbMemFunT TimeoutDialer; AsyncCall::Pointer timeoutCall = JobCallback(9, 5, TimeoutDialer, this, - Ftp::Client::timeout); + Ftp::Client::timeout); commSetConnTimeout(data.conn, Config.Timeout.read, timeoutCall); } diff --git a/src/clients/FtpClient.h b/src/clients/FtpClient.h index 12f2e20f26..6279203fd0 100644 --- a/src/clients/FtpClient.h +++ b/src/clients/FtpClient.h @@ -9,7 +9,8 @@ #include "Server.h" class String; -namespace Ftp { +namespace Ftp +{ extern const char *const crlf; diff --git a/src/clients/FtpGateway.cc b/src/clients/FtpGateway.cc index 4daf7ae0ab..4a06d5c101 100644 --- a/src/clients/FtpGateway.cc +++ b/src/clients/FtpGateway.cc @@ -72,7 +72,8 @@ #include -namespace Ftp { +namespace Ftp +{ /** \defgroup ServerProtocolFTPInternal Server-Side FTP Internals @@ -365,8 +366,8 @@ Ftp::Gateway::dataClosed(const CommCloseCbParams &io) } Ftp::Gateway::Gateway(FwdState *fwdState): - AsyncJob("FtpStateData"), - Ftp::Client(fwdState) + AsyncJob("FtpStateData"), + Ftp::Client(fwdState) { const char *url = entry->url(); debugs(9, 3, HERE << "'" << url << "'" ); diff --git a/src/clients/FtpRelay.cc b/src/clients/FtpRelay.cc index 780badeb4f..11219052dd 100644 --- a/src/clients/FtpRelay.cc +++ b/src/clients/FtpRelay.cc @@ -14,13 +14,14 @@ #include "HttpHdrCc.h" #include "HttpRequest.h" #include "SBuf.h" -#include "servers/FtpServer.h" #include "Server.h" +#include "servers/FtpServer.h" #include "SquidTime.h" #include "Store.h" #include "wordlist.h" -namespace Ftp { +namespace Ftp +{ /// An FTP client receiving native FTP commands from our FTP server /// (Ftp::Server), forwarding them to the next FTP hop, @@ -160,9 +161,8 @@ Ftp::Relay::start() { if (!master().clientReadGreeting) Ftp::Client::start(); - else - if (serverState() == fssHandleDataRequest || - serverState() == fssHandleUploadRequest) + else if (serverState() == fssHandleDataRequest || + serverState() == fssHandleUploadRequest) handleDataRequest(); else sendCommand(); @@ -363,7 +363,7 @@ Ftp::Relay::forwardPreliminaryReply(const PreliminaryCb cb) // the Sink will use this to call us back after writing 1xx to the client typedef NullaryMemFunT CbDialer; const AsyncCall::Pointer call = JobCallback(11, 3, CbDialer, this, - Ftp::Relay::proceedAfterPreliminaryReply); + Ftp::Relay::proceedAfterPreliminaryReply); CallJobHere1(9, 4, request->clientConnectionManager, ConnStateData, ConnStateData::sendControlMsg, HttpControlMsg(reply, call)); @@ -486,9 +486,9 @@ Ftp::Relay::sendCommand() debugs(9, 5, "command: " << cmd << ", no parameters"); if (serverState() == fssHandlePasv || - serverState() == fssHandleEpsv || - serverState() == fssHandleEprt || - serverState() == fssHandlePort) { + serverState() == fssHandleEpsv || + serverState() == fssHandleEprt || + serverState() == fssHandlePort) { sendPassive(); return; } diff --git a/src/clients/forward.h b/src/clients/forward.h index d32c4612dd..44aca5ef0d 100644 --- a/src/clients/forward.h +++ b/src/clients/forward.h @@ -8,7 +8,8 @@ class AsyncJob; template class CbcPointer; typedef CbcPointer AsyncJobPointer; -namespace Ftp { +namespace Ftp +{ /// A new FTP Gateway job AsyncJobPointer StartGateway(FwdState *const fwdState); diff --git a/src/ftp/Elements.h b/src/ftp/Elements.h index 87f74e4a8d..769de2f433 100644 --- a/src/ftp/Elements.h +++ b/src/ftp/Elements.h @@ -6,7 +6,8 @@ class SBuf; class HttpReply; -namespace Ftp { +namespace Ftp +{ /// Create an internal HttpReply structure to house FTP control response info. HttpReply *HttpReplyWrapper(const int ftpStatus, const char *ftpReason, const Http::StatusCode httpStatus, const int64_t clen); diff --git a/src/ftp/Parsing.h b/src/ftp/Parsing.h index 89dd64a138..56cd879ce9 100644 --- a/src/ftp/Parsing.h +++ b/src/ftp/Parsing.h @@ -3,7 +3,8 @@ #include "ip/forward.h" -namespace Ftp { +namespace Ftp +{ /// parses and validates "A1,A2,A3,A4,P1,P2" IP,port sequence bool ParseIpPort(const char *buf, const char *forceIp, Ip::Address &addr); diff --git a/src/parser/Tokenizer.cc b/src/parser/Tokenizer.cc index c735414d19..a7dbdba6b6 100644 --- a/src/parser/Tokenizer.cc +++ b/src/parser/Tokenizer.cc @@ -28,10 +28,10 @@ #endif #endif - /// convenience method: consumes up to n bytes, counts, and returns them SBuf -Parser::Tokenizer::consume(const SBuf::size_type n) { +Parser::Tokenizer::consume(const SBuf::size_type n) +{ // careful: n may be npos! const SBuf result = buf_.consume(n); parsed_ += result.length(); @@ -40,7 +40,8 @@ Parser::Tokenizer::consume(const SBuf::size_type n) { /// convenience method: consume()s up to n bytes and returns their count SBuf::size_type -Parser::Tokenizer::success(const SBuf::size_type n) { +Parser::Tokenizer::success(const SBuf::size_type n) +{ return consume(n).length(); } diff --git a/src/servers/FtpServer.cc b/src/servers/FtpServer.cc index 51e6a4a394..e17761ab0f 100644 --- a/src/servers/FtpServer.cc +++ b/src/servers/FtpServer.cc @@ -5,13 +5,13 @@ #include "squid.h" #include "base/CharacterSet.h" #include "base/Subscription.h" +#include "client_side_reply.h" +#include "client_side_request.h" #include "clientStream.h" #include "comm/ConnOpener.h" #include "comm/Read.h" #include "comm/TcpAcceptor.h" #include "comm/Write.h" -#include "client_side_reply.h" -#include "client_side_request.h" #include "errorpage.h" #include "fd.h" #include "ftp/Elements.h" @@ -32,7 +32,8 @@ CBDATA_NAMESPACED_CLASS_INIT(Ftp, Server); -namespace Ftp { +namespace Ftp +{ static void PrintReply(MemBuf &mb, const HttpReply *reply, const char *const prefix = ""); static bool SupportedCommand(const SBuf &name); static bool CommandHasPathParameter(const SBuf &cmd); @@ -197,7 +198,7 @@ Ftp::Server::shovelUploadData() debugs(33, 5, "handling FTP request data for " << clientConnection); const size_t putSize = bodyPipe->putMoreData(uploadBuf, - uploadAvailSize); + uploadAvailSize); if (putSize > 0) { uploadAvailSize -= putSize; if (uploadAvailSize > 0) @@ -262,8 +263,8 @@ Ftp::StartListening() // direct new connections accepted by listenConn to Accept() typedef CommCbFunPtrCallT AcceptCall; RefCount subCall = commCbCall(5, 5, "Ftp::Server::AcceptCtrlConnection", - CommAcceptCbPtrFun(Ftp::Server::AcceptCtrlConnection, - CommAcceptCbParams(NULL))); + CommAcceptCbPtrFun(Ftp::Server::AcceptCtrlConnection, + CommAcceptCbParams(NULL))); clientStartListeningOn(s, subCall, Ipc::fdnFtpSocket); } } @@ -393,8 +394,7 @@ Ftp::Server::acceptDataConnection(const CommAcceptCbParams ¶ms) debugs(33, 5, "late data connection?"); closeDataConnection(); // in case we are still listening params.conn->close(); - } else - if (params.conn->remote != clientConnection->remote) { + } else if (params.conn->remote != clientConnection->remote) { debugs(33, 2, "rogue data conn? ctrl: " << clientConnection->remote); params.conn->close(); // Some FTP servers close control connection here, but it may make @@ -489,7 +489,7 @@ Ftp::Server::writeCustomReply(const int code, const char *msg, const HttpReply * assert(99 < code && code < 1000); const bool sendDetails = reply != NULL && - reply->header.has(HDR_FTP_STATUS) && reply->header.has(HDR_FTP_REASON); + reply->header.has(HDR_FTP_STATUS) && reply->header.has(HDR_FTP_REASON); MemBuf mb; mb.init(); @@ -621,7 +621,7 @@ Ftp::Server::parseOneRequest(Http::ProtocolVersion &ver) Http::METHOD_PUT : Http::METHOD_GET; const SBuf *path = params.length() && CommandHasPathParameter(cmd) ? - ¶ms : NULL; + ¶ms : NULL; calcUri(path); char *newUri = xstrdup(uri.c_str()); HttpRequest *const request = HttpRequest::CreateFromUrlAndMethod(newUri, method); @@ -682,7 +682,7 @@ Ftp::Server::handleReply(HttpReply *reply, StoreIOBuffer data) assert(context != NULL); if (context->http && context->http->al != NULL && - !context->http->al->reply && reply) { + !context->http->al->reply && reply) { context->http->al->reply = reply; HTTPMSGLOCK(context->http->al->reply); } @@ -905,7 +905,8 @@ Ftp::Server::wroteReplyData(const CommIoCbParams &io) /// ClientStream checks after (actual or skipped) reply data writing void -Ftp::Server::replyDataWritingCheckpoint() { +Ftp::Server::replyDataWritingCheckpoint() +{ switch (getCurrentContext()->socketState()) { case STREAM_NONE: debugs(33, 3, "Keep going"); @@ -1066,8 +1067,8 @@ Ftp::Server::writeForwardedReplyAndCall(const HttpReply *reply, AsyncCall::Point // Status 125 or 150 implies upload or data request, but we still check // the state in case the server is buggy. if ((scode == 125 || scode == 150) && - (master.serverState == fssHandleUploadRequest || - master.serverState == fssHandleDataRequest)) { + (master.serverState == fssHandleUploadRequest || + master.serverState == fssHandleDataRequest)) { if (checkDataConnPost()) { // If the data connection is ready, start reading data (here) // and forward the response to client (further below). @@ -1174,8 +1175,8 @@ Ftp::Server::wroteReply(const CommIoCbParams &io) switch (socketState) { case STREAM_UNPLANNED_COMPLETE: case STREAM_FAILED: - io.conn->close(); - return; + io.conn->close(); + return; case STREAM_NONE: case STREAM_COMPLETE: @@ -1189,7 +1190,8 @@ Ftp::Server::wroteReply(const CommIoCbParams &io) } bool -Ftp::Server::handleRequest(String &cmd, String ¶ms) { +Ftp::Server::handleRequest(String &cmd, String ¶ms) +{ HttpRequest *request = getCurrentContext()->http->request; Must(request); @@ -1527,7 +1529,7 @@ Ftp::Server::checkDataConnPre() typedef CommCbMemFunT Dialer; connector = JobCallback(17, 3, Dialer, this, Ftp::Server::connectedForData); Comm::ConnOpener *cs = new Comm::ConnOpener(dataConn, connector, - Config.Timeout.connect); + Config.Timeout.connect); AsyncJob::Start(cs); return false; // ConnStateData::processFtpRequest waits handleConnectDone } diff --git a/src/servers/FtpServer.h b/src/servers/FtpServer.h index 4f6f8a84af..574e26efc3 100644 --- a/src/servers/FtpServer.h +++ b/src/servers/FtpServer.h @@ -7,7 +7,8 @@ #include "client_side.h" -namespace Ftp { +namespace Ftp +{ typedef enum { fssBegin, diff --git a/src/servers/HttpServer.cc b/src/servers/HttpServer.cc index 58646d1b4a..1f3dab3cca 100644 --- a/src/servers/HttpServer.cc +++ b/src/servers/HttpServer.cc @@ -11,7 +11,8 @@ #include "servers/forward.h" #include "SquidConfig.h" -namespace Http { +namespace Http +{ /// Manages a connection from an HTTP client. class Server: public ConnStateData diff --git a/src/servers/forward.h b/src/servers/forward.h index 50e20e5dda..47def1d67b 100644 --- a/src/servers/forward.h +++ b/src/servers/forward.h @@ -5,21 +5,24 @@ class MasterXaction; template class RefCount; typedef RefCount MasterXactionPointer; -namespace Http { +namespace Http +{ /// create a new HTTP connection handler; never returns NULL ConnStateData *NewServer(MasterXactionPointer &xact); } // namespace Http -namespace Https { +namespace Https +{ /// create a new HTTPS connection handler; never returns NULL ConnStateData *NewServer(MasterXactionPointer &xact); } // namespace Https -namespace Ftp { +namespace Ftp +{ /// accept connections on all configured ftp_ports void StartListening();