Changeset 5503


Ignore:
Timestamp:
Jul 13, 2017, 11:11:39 AM (17 months ago)
Author:
Juanma
Message:

Initial release

Location:
squid-ssl/trunk/fuentes
Files:
1 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • squid-ssl/trunk/fuentes/debian/patches/01-cf.data.debian.patch

    r5498 r5503  
    33--- a/src/cf.data.pre
    44+++ b/src/cf.data.pre
    5 @@ -1155,11 +1155,11 @@ NOCOMMENT_START
     5@@ -1206,11 +1206,11 @@
    66 # Example rule allowing access from your local networks.
    77 # Adapt to list your (internal) IP networks from where browsing
     
    2020 acl SSL_ports port 443
    2121 acl Safe_ports port 80         # http
    22 @@ -1408,7 +1408,7 @@ http_access deny manager
     22@@ -1459,7 +1459,7 @@
    2323 # Example rule allowing access from your local networks.
    2424 # Adapt localnet in the ACL section to list your (internal) IP networks
     
    2929 
    3030 # And finally deny all other access to this proxy
    31 @@ -4431,7 +4431,7 @@ DOC_END
     31@@ -4533,7 +4533,7 @@
    3232 
    3333 NAME: logfile_rotate
     
    3838 DOC_START
    3939        Specifies the number of logfile rotations to make when you
    40 @@ -4450,6 +4450,9 @@ DOC_START
     40@@ -4552,6 +4552,9 @@
    4141 
    4242        Note, from Squid-3.1 this option is only a default for cache.log,
     
    4848 
    4949 NAME: mime_table
    50 @@ -8794,8 +8797,8 @@ DOC_START
     50@@ -8896,8 +8899,8 @@
    5151 
    5252        WARNING:
  • squid-ssl/trunk/fuentes/debian/patches/CVE-2016-10003.patch

    r5501 r5503  
    55--- a/src/client_side_reply.cc
    66+++ b/src/client_side_reply.cc
    7 @@ -545,7 +545,6 @@
    8          debugs(88, 5, "negative-HIT");
    9          http->logType = LOG_TCP_NEGATIVE_HIT;
    10          sendMoreData(result);
    11 -        return;
    12      } else if (blockedHit()) {
    13          debugs(88, 5, "send_hit forces a MISS");
    14          http->logType = LOG_TCP_MISS;
    15 @@ -597,29 +596,27 @@
    16              http->logType = LOG_TCP_MISS;
    17              processMiss();
    18          }
    19 -        return;
    20      } else if (r->conditional()) {
    21          debugs(88, 5, "conditional HIT");
    22 -        if (processConditional(result))
    23 -            return;
    24 -    }
    25 -
    26 -    /*
    27 -     * plain ol' cache hit
    28 -     */
    29 -    debugs(88, 5, "plain old HIT");
    30 +        processConditional(result);
    31 +    } else {
    32 +        /*
    33 +         * plain ol' cache hit
    34 +         */
    35 +        debugs(88, 5, "plain old HIT");
    36  
    37  #if USE_DELAY_POOLS
    38 -    if (e->store_status != STORE_OK)
    39 -        http->logType = LOG_TCP_MISS;
    40 -    else
    41 +        if (e->store_status != STORE_OK)
    42 +            http->logType = LOG_TCP_MISS;
    43 +        else
    44  #endif
    45 -        if (e->mem_status == IN_MEMORY)
    46 -            http->logType = LOG_TCP_MEM_HIT;
    47 -        else if (Config.onoff.offline)
    48 -            http->logType = LOG_TCP_OFFLINE_HIT;
    49 +            if (e->mem_status == IN_MEMORY)
    50 +                http->logType = LOG_TCP_MEM_HIT;
    51 +            else if (Config.onoff.offline)
    52 +                http->logType = LOG_TCP_OFFLINE_HIT;
    53  
    54 -    sendMoreData(result);
    55 +        sendMoreData(result);
    56 +    }
    57  }
    58  
    59  /**
    60 @@ -713,16 +710,17 @@
    61  }
    62  
    63  /// process conditional request from client
    64 -bool
    65 +void
    66  clientReplyContext::processConditional(StoreIOBuffer &result)
    67  {
    68      StoreEntry *const e = http->storeEntry();
    69  
    70      if (e->getReply()->sline.status() != Http::scOkay) {
    71 -        debugs(88, 4, "Reply code " << e->getReply()->sline.status() << " != 200");
    72 +        debugs(88, 4, "clientReplyContext::processConditional: Reply code " <<
    73 +               e->getReply()->sline.status() << " != 200");
    74          http->logType = LOG_TCP_MISS;
    75          processMiss();
    76 -        return true;
    77 +        return;
     7@@ -474,6 +474,16 @@
     8         return;
    789     }
    7910 
    80      HttpRequest &r = *http->request;
    81 @@ -730,39 +728,51 @@
    82      if (r.header.has(HDR_IF_MATCH) && !e->hasIfMatchEtag(r)) {
    83          // RFC 2616: reply with 412 Precondition Failed if If-Match did not match
    84          sendPreconditionFailedError();
    85 -        return true;
     11+    // The previously identified hit suddenly became unsharable!
     12+    // This is common for collapsed forwarding slaves but might also
     13+    // happen to regular hits because we are called asynchronously.
     14+    if (EBIT_TEST(e->flags, KEY_PRIVATE)) {
     15+        debugs(88, 3, "unsharable " << *e << ". MISS");
     16+        http->logType = LOG_TCP_MISS;
     17+        processMiss();
    8618+        return;
    87      }
    88  
    89 +    bool matchedIfNoneMatch = false;
    90      if (r.header.has(HDR_IF_NONE_MATCH)) {
    91 -        // RFC 7232: If-None-Match recipient MUST ignore IMS
    92 -        r.flags.ims = false;
    93 -        r.ims = -1;
    94 -        r.imslen = 0;
    95 -        r.header.delById(HDR_IF_MODIFIED_SINCE);
    96 +        if (!e->hasIfNoneMatchEtag(r)) {
    97 +            // RFC 2616: ignore IMS if If-None-Match did not match
    98 +            r.flags.ims = false;
    99 +            r.ims = -1;
    100 +            r.imslen = 0;
    101 +            r.header.delById(HDR_IF_MODIFIED_SINCE);
    102 +            http->logType = LOG_TCP_MISS;
    103 +            sendMoreData(result);
    104 +            return;
    105 +        }
    106  
    107 -        if (e->hasIfNoneMatchEtag(r)) {
    108 +        if (!r.flags.ims) {
    109 +            // RFC 2616: if If-None-Match matched and there is no IMS,
    110 +            // reply with 304 Not Modified or 412 Precondition Failed
    111              sendNotModifiedOrPreconditionFailedError();
    112 -            return true;
    113 +            return;
    114          }
    115  
    116 -        // None-Match is true (no ETag matched); treat as an unconditional hit
    117 -        return false;
    118 +        // otherwise check IMS below to decide if we reply with 304 or 412
    119 +        matchedIfNoneMatch = true;
    120      }
    121  
    122      if (r.flags.ims) {
    123          // handle If-Modified-Since requests from the client
    124          if (e->modifiedSince(&r)) {
    125 -            // Modified-Since is true; treat as an unconditional hit
    126 -            return false;
    127 +            http->logType = LOG_TCP_IMS_HIT;
    128 +            sendMoreData(result);
    129 +            return;
    130 +        }
    131  
    132 -        } else {
    133 -            // otherwise reply with 304 Not Modified
    134 -            sendNotModified();
    135 +        if (matchedIfNoneMatch) {
    136 +            // If-None-Match matched, reply with 304 Not Modified or
    137 +            // 412 Precondition Failed
    138 +            sendNotModifiedOrPreconditionFailedError();
    139 +            return;
    140          }
    141 -        return true;
    142 -    }
    143  
    144 -    return false;
    145 +        // otherwise reply with 304 Not Modified
    146 +        sendNotModified();
    14719+    }
    148  }
    149  
    150  /// whether squid.conf send_hit prevents us from serving this hit
    151 @@ -1909,12 +1919,7 @@
    152      StoreEntry *e = http->storeEntry();
    153      const time_t timestamp = e->timestamp;
    154      HttpReply *const temprep = e->getReply()->make304();
    155 -    // log as TCP_INM_HIT if code 304 generated for
    156 -    // If-None-Match request
    157 -    if (!http->request->flags.ims)
    158 -        http->logType = LOG_TCP_INM_HIT;
    159 -    else
    160 -        http->logType = LOG_TCP_IMS_HIT;
    161 +    http->logType = LOG_TCP_IMS_HIT;
    162      removeClientStoreReference(&sc, http);
    163      createStoreEntry(http->request->method, RequestFlags());
    164      e = http->storeEntry();
     20+
     21     if (result.length == 0) {
     22         debugs(88, 5, "store IO buffer has no content. MISS");
     23         /* the store couldn't get enough data from the file for us to id the
  • squid-ssl/trunk/fuentes/src/LogTags.h

    r5502 r5503  
    2828    LOG_TCP_CLIENT_REFRESH_MISS,
    2929    LOG_TCP_IMS_HIT,
    30     LOG_TCP_INM_HIT,
    3130    LOG_TCP_SWAPFAIL_MISS,
    3231    LOG_TCP_NEGATIVE_HIT,
     
    5554        (code == LOG_TCP_HIT) ||
    5655        (code == LOG_TCP_IMS_HIT) ||
    57         (code == LOG_TCP_INM_HIT) ||
    5856        (code == LOG_TCP_REFRESH_FAIL_OLD) ||
    5957        (code == LOG_TCP_REFRESH_UNMODIFIED) ||
  • squid-ssl/trunk/fuentes/src/Makefile.am

    r5502 r5503  
    910910DEFAULT_CONFIG_DIR      = $(sysconfdir)
    911911DEFAULT_CONFIG_FILE     = $(DEFAULT_CONFIG_DIR)/squid.conf
    912 DEFAULT_MIME_TABLE      = $(datadir)/mime.conf
     912DEFAULT_MIME_TABLE      = $(DEFAULT_CONFIG_DIR)/mime.conf
    913913DEFAULT_SSL_CRTD        = $(libexecdir)/`echo ssl_crtd  | sed '$(transform);s/$$/$(EXEEXT)/'`
    914914DEFAULT_LOG_PREFIX      = $(DEFAULT_LOG_DIR)
  • squid-ssl/trunk/fuentes/src/Makefile.in

    r5502 r5503  
    32583258DEFAULT_CONFIG_DIR = $(sysconfdir)
    32593259DEFAULT_CONFIG_FILE = $(DEFAULT_CONFIG_DIR)/squid.conf
    3260 DEFAULT_MIME_TABLE = $(datadir)/mime.conf
     3260DEFAULT_MIME_TABLE = $(DEFAULT_CONFIG_DIR)/mime.conf
    32613261DEFAULT_SSL_CRTD = $(libexecdir)/`echo ssl_crtd  | sed '$(transform);s/$$/$(EXEEXT)/'`
    32623262DEFAULT_LOG_PREFIX = $(DEFAULT_LOG_DIR)
  • squid-ssl/trunk/fuentes/src/cf.data.pre

    r5502 r5503  
    12071207# Adapt to list your (internal) IP networks from where browsing
    12081208# should be allowed
    1209 #acl localnet src 10.0.0.0/8    # RFC1918 possible internal network
    1210 #acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
    1211 #acl localnet src 192.168.0.0/16        # RFC1918 possible internal network
    1212 #acl localnet src fc00::/7       # RFC 4193 local private network range
    1213 #acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines
     1209acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
     1210acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
     1211acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
     1212acl localnet src fc00::/7       # RFC 4193 local private network range
     1213acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines
    12141214
    12151215acl SSL_ports port 443
     
    14601460# Adapt localnet in the ACL section to list your (internal) IP networks
    14611461# from where browsing should be allowed
    1462 #http_access allow localnet
     1462http_access allow localnet
    14631463http_access allow localhost
    14641464
     
    32113211                        reference a combined file containing both the
    32123212                        certificate and the key.
    3213 
    3214         Notes:
    3215        
    3216         On Debian/Ubuntu systems a default snakeoil certificate is
    3217     available in /etc/ssl and users can set:
    3218 
    3219                 cert=/etc/ssl/certs/ssl-cert-snakeoil.pem
    3220 
    3221         and
    3222 
    3223                 key=/etc/ssl/private/ssl-cert-snakeoil.key
    3224 
    3225         for testing.
    32263213       
    32273214        sslversion=1|2|3|4|5|6
     
    45474534NAME: logfile_rotate
    45484535TYPE: int
    4549 DEFAULT: 0
     4536DEFAULT: 10
    45504537LOC: Config.Log.rotateNumber
    45514538DOC_START
     
    45664553        Note, from Squid-3.1 this option is only a default for cache.log,
    45674554        that log can be rotated separately by using debug_options.
    4568 
    4569         Note2, for Debian/Linux the default of logfile_rotate is
    4570         zero, since it includes external logfile-rotation methods.
    45714555DOC_END
    45724556
     
    54475431refresh_pattern ^gopher:        1440    0%      1440
    54485432refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
    5449 refresh_pattern (Release|Packages(.gz)*)$      0       20%     2880
    5450 # example lin deb packages
    5451 #refresh_pattern (\.deb|\.udeb)$   129600 100% 129600
    54525433refresh_pattern .               0       20%     4320
    54535434NOCOMMENT_END
     
    89168897        WARNING:
    89178898          This option will restrict the situations under which IPv6
    8918           connectivity is used (and tested), potentially hiding network
    8919           problems which would otherwise be detected and warned about.
     8899          connectivity is used (and tested). Hiding network problems
     8900          which would otherwise be detected and warned about.
    89208901DOC_END
    89218902
  • squid-ssl/trunk/fuentes/src/client_side.cc

    r5502 r5503  
    416416        break;
    417417
    418     case LOG_TCP_INM_HIT:
    419418    case LOG_TCP_IMS_HIT:
    420419        statCounter.client_http.nearMissSvcTime.count(svc_time);
     
    26622661            return;
    26632662        }
    2664 
    2665         // when absolute-URI is provided Host header should be ignored. However
    2666         // some code still uses Host directly so normalize it.
    2667         // For now preserve the case where Host is completely absent. That matters.
    2668         if (request->header.has(HDR_HOST)) {
    2669             const char *host = request->header.getStr(HDR_HOST);
    2670             SBuf authority(request->GetHost());
    2671             if (request->port != urlDefaultPort(request->url.getScheme()))
    2672                 authority.appendf(":%d", request->port);
    2673             debugs(33, 5, "URL domain " << authority << " overrides header Host: " << host);
    2674             // URL authority overrides Host header
    2675             request->header.delById(HDR_HOST);
    2676             request->header.putStr(HDR_HOST, authority.c_str());
    2677         }
    26782663    }
    26792664
  • squid-ssl/trunk/fuentes/src/client_side_reply.h

    r5502 r5503  
    115115    int checkTransferDone();
    116116    void processOnlyIfCachedMiss();
    117     bool processConditional(StoreIOBuffer &result);
     117    void processConditional(StoreIOBuffer &result);
    118118    void cacheHit(StoreIOBuffer result);
    119119    void handleIMSReply(StoreIOBuffer result);
  • squid-ssl/trunk/fuentes/src/client_side_request.cc

    r5502 r5503  
    142142    al = new AccessLogEntry;
    143143    al->cache.start_time = current_time;
    144     if (aConn) {
    145         al->tcpClient = clientConnection = aConn->clientConnection;
    146         al->cache.port = aConn->port;
    147         al->cache.caddr = aConn->log_addr;
     144    al->tcpClient = clientConnection = aConn->clientConnection;
     145    al->cache.port = aConn->port;
     146    al->cache.caddr = aConn->log_addr;
    148147
    149148#if USE_OPENSSL
    150         if (aConn->clientConnection != NULL && aConn->clientConnection->isOpen()) {
    151             if (SSL *ssl = fd_table[aConn->clientConnection->fd].ssl)
    152                 al->cache.sslClientCert.reset(SSL_get_peer_certificate(ssl));
    153         }
    154 #endif
    155     }
     149    if (aConn->clientConnection != NULL && aConn->clientConnection->isOpen()) {
     150        if (SSL *ssl = fd_table[aConn->clientConnection->fd].ssl)
     151            al->cache.sslClientCert.reset(SSL_get_peer_certificate(ssl));
     152    }
     153#endif
    156154    dlinkAdd(this, &active, &ClientActiveRequests);
    157155#if USE_ADAPTATION
  • squid-ssl/trunk/fuentes/src/esi/Context.h

    r5502 r5503  
    1414#include "esi/Element.h"
    1515#include "esi/Parser.h"
    16 #include "HttpReply.h"
    1716#include "http/StatusCode.h"
    1817
     
    9392    Http::StatusCode errorstatus; /* if we error, what code to return */
    9493    char *errormessage; /* error to pass to error page */
    95     HttpReply::Pointer rep; /* buffered until we pass data downstream */
     94    HttpReply *rep; /* buffered until we pass data downstream */
    9695    ESISegment::Pointer buffered; /* unprocessed data - for whatever reason */
    9796    ESISegment::Pointer incoming;
  • squid-ssl/trunk/fuentes/src/esi/Esi.cc

    r5502 r5503  
    574574#endif
    575575
    576     if (!(rep != NULL || (outbound.getRaw() &&
     576    if (!(rep || (outbound.getRaw() &&
    577577                  outbound->len && (outbound_offset <= outbound->len)))) {
    578578        debugs(86, 5, "ESIContext::send: Nothing to send.");
     
    619619    debugs(86, 5, "ESIContext::send: this=" << this << " Client no longer wants data ");
    620620    /* Deal with re-entrancy */
    621     HttpReply::Pointer temprep = rep;
     621    HttpReply *temprep = rep;
    622622    rep = NULL; /* freed downstream */
    623623
    624     if (temprep != NULL && varState)
    625         varState->buildVary(temprep.getRaw());
     624    if (temprep && varState)
     625        varState->buildVary (temprep);
    626626
    627627    {
     
    630630        tempBuffer.offset = pos - len;
    631631        tempBuffer.data = next->readBuffer.data;
    632         clientStreamCallback (thisNode, http, temprep.getRaw(), tempBuffer);
     632        clientStreamCallback (thisNode, http, temprep, tempBuffer);
    633633    }
    634634
     
    967967    int specifiedattcount = attrCount * 2;
    968968    char *position;
    969     Must(ellen < sizeof(localbuf)); /* prevent unexpected overruns. */
     969    assert (ellen < sizeof (localbuf)); /* prevent unexpected overruns. */
    970970
    971971    debugs(86, 5, "ESIContext::Start: element '" << el << "' with " << specifiedattcount << " tags");
     
    981981        localbuf[0] = '<';
    982982        localbuf[1] = '\0';
    983         xstrncpy(&localbuf[1], el, sizeof(localbuf) - 2);
     983        assert (xstrncpy (&localbuf[1], el, sizeof(localbuf) - 2));
    984984        position = localbuf + strlen (localbuf);
    985985
    986986        for (i = 0; i < specifiedattcount && attr[i]; i += 2) {
    987             Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 1);
    988987            *position = ' ';
    989988            ++position;
    990989            /* TODO: handle thisNode gracefully */
    991             xstrncpy(position, attr[i], sizeof(localbuf) - (position - localbuf));
     990            assert (xstrncpy (position, attr[i], sizeof(localbuf) + (position - localbuf)));
    992991            position += strlen (position);
    993             Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 2);
    994992            *position = '=';
    995993            ++position;
     
    1000998            while ((ch = *chPtr++) != '\0') {
    1001999                if (ch == '\"') {
    1002                     Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 6);
    1003                     xstrncpy(position, "&quot;", sizeof(localbuf) - (position-localbuf));
     1000                    assert( xstrncpy(position, "&quot;", sizeof(localbuf) + (position-localbuf)) );
    10041001                    position += 6;
    10051002                } else {
    1006                     Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 1);
    10071003                    *position = ch;
    10081004                    ++position;
    10091005                }
    10101006            }
    1011             Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 1);
     1007            position += strlen (position);
    10121008            *position = '\"';
    10131009            ++position;
    10141010        }
    10151011
    1016         Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 2);
    10171012        *position = '>';
    10181013        ++position;
     
    11001095
    11011096    case ESIElement::ESI_ELEMENT_NONE:
    1102         Must(ellen < sizeof(localbuf) - 3); /* prevent unexpected overruns. */
     1097        assert (ellen < sizeof (localbuf)); /* prevent unexpected overruns. */
    11031098        /* Add elements we aren't interested in */
    11041099        localbuf[0] = '<';
    11051100        localbuf[1] = '/';
    1106         xstrncpy(&localbuf[2], el, sizeof(localbuf) - 3);
     1101        assert (xstrncpy (&localbuf[2], el, sizeof(localbuf) - 3));
    11071102        position = localbuf + strlen (localbuf);
    11081103        *position = '>';
     
    12601255    }
    12611256
    1262     if (rep != NULL && !parserState.inited())
     1257    if (rep && !parserState.inited())
    12631258        parserState.init(this);
    12641259
     
    13991394    debugs(86, 5, HERE << "Freeing for this=" << this);
    14001395
    1401     rep = NULL; // refcounted
     1396    HTTPMSGUNLOCK(rep);
    14021397
    14031398    finishChildren ();
  • squid-ssl/trunk/fuentes/src/icmp/Icmp6.cc

    r5502 r5503  
    257257
    258258        ip = (struct ip6_hdr *) pkt;
    259         NP: echo size needs to +sizeof(ip6_hdr);
     259        pkt += sizeof(ip6_hdr);
    260260
    261261    debugs(42, DBG_CRITICAL, HERE << "ip6_nxt=" << ip->ip6_nxt <<
     
    268268
    269269    icmp6header = (struct icmp6_hdr *) pkt;
     270    pkt += sizeof(icmp6_hdr);
    270271
    271272    if (icmp6header->icmp6_type != ICMP6_ECHO_REPLY) {
     
    292293    }
    293294
    294     echo = (icmpEchoData *) (pkt + sizeof(icmp6_hdr));
     295    echo = (icmpEchoData *) pkt;
    295296
    296297    preply.opcode = echo->opcode;
  • squid-ssl/trunk/fuentes/src/mime_header.cc

    r5502 r5503  
    3737    debugs(25, 5, "mime_get_header: looking for '" << name << "'");
    3838
    39     for (p = mime; *p; p += strcspn(p, "\n")) {
    40         if (strcmp(p, "\n\r\n") == 0 || strcmp(p, "\n\n") == 0)
     39    for (p = mime; *p; p += strcspn(p, "\n\r")) {
     40        if (strcmp(p, "\r\n\r\n") == 0 || strcmp(p, "\n\n") == 0)
    4141            return NULL;
    4242
    43         if (*p == '\n')
     43        while (xisspace(*p))
    4444            ++p;
    4545
  • squid-ssl/trunk/fuentes/src/tests/stub_cbdata.cc

    r5502 r5503  
    1414
    1515void cbdataRegisterWithCacheManager(void) STUB
    16 void *cbdataInternalAlloc(cbdata_type type, const char *, int sz) {
    17     return xcalloc(1, sz);
    18 }
    19 void *cbdataInternalFree(void *p, const char *, int) {
    20     xfree(p);
    21     return NULL;
    22 }
     16
    2317#if USE_CBDATA_DEBUG
    2418void *cbdataInternalAllocDbg(cbdata_type type, const char *, int) STUB_RETVAL(NULL)
  • squid-ssl/trunk/fuentes/src/tests/stub_mem.cc

    r5502 r5503  
    1515#define STUB_API "stub_mem.cc"
    1616#include "Mem.h"
    17 #include "tests/STUB.h"
     17#include "STUB.h"
    1818
    1919void
  • squid-ssl/trunk/fuentes/tools/Makefile.am

    r5502 r5503  
    3535        cp $(top_srcdir)/src/tests/stub_debug.cc .
    3636
    37 MemBuf.cc: $(top_srcdir)/src/MemBuf.cc
    38         cp $(top_srcdir)/src/MemBuf.cc $@
    39 
    4037time.cc: $(top_srcdir)/src/time.cc
    4138        cp $(top_srcdir)/src/time.cc .
    42 
    43 stub_cbdata.cc: $(top_srcdir)/src/tests/stub_cbdata.cc
    44         cp $(top_srcdir)/src/tests/stub_cbdata.cc $@
    45 
    46 stub_mem.cc: $(top_srcdir)/src/tests/stub_mem.cc
    47         cp $(top_srcdir)/src/tests/stub_mem.cc $@
    4839
    4940# stock tools for unit tests - library independent versions of dlink_list
     
    5243# Neither of these should be disted from here.
    5344TESTSOURCES= test_tools.cc
    54 CLEANFILES += test_tools.cc MemBuf.cc stub_debug.cc time.cc stub_cbdata.cc stub_mem.cc
     45CLEANFILES += test_tools.cc stub_debug.cc time.cc
    5546
    5647## ##### helper-mux #####
     
    7061
    7162cachemgr__CGIEXT__SOURCES = cachemgr.cc \
    72         MemBuf.cc \
    73         stub_cbdata.cc \
    7463        stub_debug.cc \
    75         stub_mem.cc \
    7664        test_tools.cc \
    7765        time.cc
  • squid-ssl/trunk/fuentes/tools/cachemgr.cc

    r5502 r5503  
    1212#include "html_quote.h"
    1313#include "ip/Address.h"
    14 #include "MemBuf.h"
    1514#include "rfc1123.h"
    1615#include "rfc1738.h"
     
    425424}
    426425
    427 static void
    428 munge_menu_line(MemBuf &out, const char *buf, cachemgr_request * req)
     426static const char *
     427munge_menu_line(const char *buf, cachemgr_request * req)
    429428{
    430429    char *x;
     
    434433    char *a_url;
    435434    char *buf_copy;
    436 
    437     const char bufLen = strlen(buf);
    438     if (bufLen < 1 || *buf != ' ') {
    439         out.append(buf, bufLen);
    440         return;
    441     }
    442 
    443     buf_copy = x = xstrndup(buf, bufLen);
     435    static char html[2 * 1024];
     436
     437    if (strlen(buf) < 1)
     438        return buf;
     439
     440    if (*buf != ' ')
     441        return buf;
     442
     443    buf_copy = x = xstrdup(buf);
    444444
    445445    a = xstrtok(&x, '\t');
     
    453453    /* no reason to give a url for a disabled action */
    454454    if (!strcmp(p, "disabled"))
    455         out.Printf("<LI type=\"circle\">%s (disabled)<A HREF=\"%s\">.</A>\n", d, a_url);
     455        snprintf(html, sizeof(html), "<LI type=\"circle\">%s (disabled)<A HREF=\"%s\">.</A>\n", d, a_url);
    456456    else
    457457        /* disable a hidden action (requires a password, but password is not in squid.conf) */
    458458        if (!strcmp(p, "hidden"))
    459             out.Printf("<LI type=\"circle\">%s (hidden)<A HREF=\"%s\">.</A>\n", d, a_url);
     459            snprintf(html, sizeof(html), "<LI type=\"circle\">%s (hidden)<A HREF=\"%s\">.</A>\n", d, a_url);
    460460        else
    461461            /* disable link if authentication is required and we have no password */
    462462            if (!strcmp(p, "protected") && !req->passwd)
    463                 out.Printf("<LI type=\"circle\">%s (requires <a href=\"%s\">authentication</a>)<A HREF=\"%s\">.</A>\n",
    464                             d, menu_url(req, "authenticate"), a_url);
     463                snprintf(html, sizeof(html), "<LI type=\"circle\">%s (requires <a href=\"%s\">authentication</a>)<A HREF=\"%s\">.</A>\n",
     464                         d, menu_url(req, "authenticate"), a_url);
    465465            else
    466466                /* highlight protected but probably available entries */
    467467                if (!strcmp(p, "protected"))
    468                     out.Printf("<LI type=\"square\"><A HREF=\"%s\"><font color=\"#FF0000\">%s</font></A>\n",
    469                                 a_url, d);
     468                    snprintf(html, sizeof(html), "<LI type=\"square\"><A HREF=\"%s\"><font color=\"#FF0000\">%s</font></A>\n",
     469                             a_url, d);
    470470
    471471    /* public entry or unknown type of protection */
    472472                else
    473                     out.Printf("<LI type=\"disk\"><A HREF=\"%s\">%s</A>\n", a_url, d);
     473                    snprintf(html, sizeof(html), "<LI type=\"disk\"><A HREF=\"%s\">%s</A>\n", a_url, d);
    474474
    475475    xfree(a_url);
    476476
    477477    xfree(buf_copy);
    478 }
    479 
    480 static void
    481 munge_other_line(MemBuf &out, const char *buf, cachemgr_request *)
     478
     479    return html;
     480}
     481
     482static const char *
     483munge_other_line(const char *buf, cachemgr_request * req)
    482484{
    483485    static const char *ttags[] = {"td", "th"};
    484486
     487    static char html[4096];
    485488    static int table_line_num = 0;
    486489    static int next_is_header = 0;
     
    489492    char *buf_copy;
    490493    char *x, *p;
     494    int l = 0;
    491495    /* does it look like a table? */
    492496
    493497    if (!strchr(buf, '\t') || *buf == '\t') {
    494498        /* nope, just text */
    495         if (table_line_num)
    496             out.append("</table>\n<pre>", 14);
    497         out.Printf("%s", html_quote(buf));
     499        snprintf(html, sizeof(html), "%s%s",
     500                 table_line_num ? "</table>\n<pre>" : "", html_quote(buf));
    498501        table_line_num = 0;
    499         return;
     502        return html;
    500503    }
    501504
    502505    /* start html table */
    503506    if (!table_line_num) {
    504         out.append("</pre><table cellpadding=\"2\" cellspacing=\"1\">\n", 46);
     507        l += snprintf(html + l, sizeof(html) - l, "</pre><table cellpadding=\"2\" cellspacing=\"1\">\n");
    505508        next_is_header = 0;
    506509    }
     
    512515
    513516    /* record starts */
    514     out.append("<tr>", 4);
     517    l += snprintf(html + l, sizeof(html) - l, "<tr>");
    515518
    516519    /* substitute '\t' */
     
    529532        }
    530533
    531         out.Printf("<%s colspan=\"%d\" align=\"%s\">%s</%s>",
    532                     ttag, column_span,
    533                     is_header ? "center" : is_number(cell) ? "right" : "left",
    534                     html_quote(cell), ttag);
     534        l += snprintf(html + l, sizeof(html) - l, "<%s colspan=\"%d\" align=\"%s\">%s</%s>",
     535                      ttag, column_span,
     536                      is_header ? "center" : is_number(cell) ? "right" : "left",
     537                      html_quote(cell), ttag);
    535538    }
    536539
    537540    xfree(buf_copy);
    538541    /* record ends */
    539     out.append("</tr>\n", 6);
     542    snprintf(html + l, sizeof(html) - l, "</tr>\n");
    540543    next_is_header = is_header && strstr(buf, "\t\t");
    541544    ++table_line_num;
     545    return html;
    542546}
    543547
     
    696700
    697701        case isBody:
    698         {
    699702            /* interpret [and reformat] cache response */
    700             MemBuf out;
    701             out.init();
     703
    702704            if (parse_menu)
    703                 munge_menu_line(out, buf, req);
     705                fputs(munge_menu_line(buf, req), stdout);
    704706            else
    705                 munge_other_line(out, buf, req);
    706 
    707             fputs(out.buf, stdout);
    708         }
    709         break;
     707                fputs(munge_other_line(buf, req), stdout);
     708
     709            break;
    710710
    711711        case isForward:
Note: See TracChangeset for help on using the changeset viewer.