]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Source Maintenance - manual run
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 8 Feb 2014 13:36:42 +0000 (06:36 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 8 Feb 2014 13:36:42 +0000 (06:36 -0700)
53 files changed:
compat/os/mswindows.h
helpers/external_acl/AD_group/ext_ad_group_acl.cc
helpers/external_acl/kerberos_ldap_group/support_resolv.cc
lib/profiler/xprof_type.h
lib/smblib/find_password.c
lib/smblib/smb-errors.c
scripts/source-maintenance.sh
src/DiskIO/Blocking/BlockingFile.cc
src/DiskIO/DiskDaemon/DiskdFile.cc
src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc
src/SBufAlgos.h
src/SBufDetailedStats.cc
src/SBufStatsAction.cc
src/acl/CertificateData.cc
src/acl/Gadgets.cc
src/adaptation/AccessCheck.h
src/adaptation/ecap/Host.cc
src/adaptation/ecap/ServiceRep.cc
src/auth/AclMaxUserIp.cc
src/auth/Config.cc
src/auth/Config.h
src/auth/UserRequest.cc
src/auth/basic/UserRequest.cc
src/auth/basic/auth_basic.cc
src/auth/digest/UserRequest.cc
src/auth/negotiate/UserRequest.cc
src/auth/ntlm/UserRequest.cc
src/base/CharacterSet.cc
src/base/CharacterSet.h
src/client_db.cc
src/client_side.cc
src/esi/Context.cc
src/esi/Include.cc
src/esi/VarState.cc
src/external_acl.cc
src/format/Format.cc
src/icp_v2.cc
src/icp_v3.cc
src/ipc/MemMap.cc
src/refresh.cc
src/ssl/Config.cc
src/ssl/support.cc
src/tests/Stub.list
src/tests/stub_EventLoop.cc
src/tests/stub_libsslsquid.cc
src/tests/testRock.cc
src/tests/testSBuf.cc
src/tests/testUfs.cc
src/urn.cc
test-suite/membanger.c
test-suite/pconn-banger.c
test-suite/tcp-banger2.c
tools/purge/conffile.cc

index cdc53dc50787404cdb1e0ef60b2214525358e12d..c63fe73ec29cf99f17d30720f4f9feba44de5119 100644 (file)
@@ -114,7 +114,6 @@ typedef unsigned long ino_t;
 #define snprintf _snprintf
 #define stat _stati64
 #define strcasecmp _stricmp
-#define strdup _strdup
 #define strlwr _strlwr
 #define strncasecmp _strnicmp
 #define tempnam _tempnam
index 6b5b9219e61ca61264ae594d1a96a2a3e5e2953f..c3d35847d1fca66474502a7da3689fe562bd105a 100644 (file)
@@ -187,7 +187,7 @@ Get_primaryGroup(IADs * pUser)
         CoTaskMemFree(pByte);
 
         *(strrchr(szSID, '-') + 1) = '\0';
-        sprintf(tmpSID, "%s%u", szSID, User_primaryGroupID);
+        snprintf(tmpSID, sizeof(tmpSID)-1, "%s%u", szSID, User_primaryGroupID);
 
         wcsize = MultiByteToWideChar(CP_ACP, 0, tmpSID, -1, wc, 0);
         wc = (wchar_t *) xmalloc(wcsize * sizeof(wchar_t));
index 8df8fd2fff501b24c5d0bfc081d8fac3cd8857dd..aa11112dd030916f652f84956507fb05da7bab58 100644 (file)
@@ -239,7 +239,7 @@ get_ldap_hostname_list(struct main_args *margs, struct hstruct **hlist, size_t n
         if (ls->domain && !strcasecmp(ls->domain, domain)) {
             debug((char *) "%s| %s: DEBUG: Found lserver@domain %s@%s\n", LogTime(), PROGRAM, ls->lserver, ls->domain);
             hp = (struct hstruct *) xrealloc(hp, sizeof(struct hstruct) * (nhosts + 1));
-            hp[nhosts].host = strdup(ls->lserver);
+            hp[nhosts].host = xstrdup(ls->lserver);
             hp[nhosts].port = -1;
             hp[nhosts].priority = -2;
             hp[nhosts].weight = -2;
@@ -247,7 +247,7 @@ get_ldap_hostname_list(struct main_args *margs, struct hstruct **hlist, size_t n
         } else if ( !ls->domain || !strcasecmp(ls->domain, "") ) {
             debug((char *) "%s| %s: DEBUG: Found lserver@domain %s@%s\n", LogTime(), PROGRAM, ls->lserver, ls->domain?ls->domain:"NULL");
             hp = (struct hstruct *) xrealloc(hp, sizeof(struct hstruct) * (nhosts + 1));
-            hp[nhosts].host = strdup(ls->lserver);
+            hp[nhosts].host = xstrdup(ls->lserver);
             hp[nhosts].port = -1;
             hp[nhosts].priority = -2;
             hp[nhosts].weight = -2;
@@ -401,7 +401,7 @@ finalise:
     debug("%s| %s: DEBUG: Adding %s to list\n", LogTime(), PROGRAM, domain);
 
     hp = (struct hstruct *) xrealloc(hp, sizeof(struct hstruct) * (nhosts + 1));
-    hp[nhosts].host = strdup(domain);
+    hp[nhosts].host = xstrdup(domain);
     hp[nhosts].port = -1;
     hp[nhosts].priority = -2;
     hp[nhosts].weight = -2;
index c45378fd6970a3c7a5564df64f763e4a6cc9c245..a7ba32a411bc41d7ce2647094c8de5e4fc10c6fd 100644 (file)
@@ -71,7 +71,6 @@ typedef enum {
     XPROF_storeGetMemSpace,
     XPROF_storeMaintainSwapSpace,
     XPROF_storeRelease,
-    XPROF_storeWriteComplete,
     XPROF_write,
     XPROF_xcalloc,
     XPROF_xmalloc,
index ae310348972b48d89dba5ada08d14d7766ec8f67..782283f1ca58c510966479641ef8b6fe42a01b2b 100644 (file)
@@ -97,7 +97,7 @@ char *print_password(char * password)
         if (((unsigned)password[i] <= ' ') || ((unsigned)password[i] > 127)) {
 
             pwd_str[j] = '\\';
-            sprintf(temp, "%03i", (int)password[i]);
+            snprintf(temp, sizeof(temp)-1, "%03i", (int)password[i]);
             strcpy(&pwd_str[j + 1], temp);
             j = j + 3;                       /* Space for \ accounted for below */
 
@@ -228,7 +228,7 @@ main(int argc, char *argv[])
 
     }
 
-    sprintf(service_name, "\\\\%s\\%s", server, service); /* Could blow up */
+    sprintf(service_name, sizeof(service_name)-1, "\\\\%s\\%s", server, service); /* Could blow up */
 
     /* Now loop through all password possibilities ... */
 
index 6813ccdf0795578c5b6efa0fdb5021d61f3d2dde..9d30d2ee4e0004d4652d8368b24e7ed48c9a0727 100644 (file)
@@ -190,7 +190,7 @@ int SMB_Get_SMB_Error_Msg(int err_class, int err_code, char *msg_buf, int len)
 
                 strncpy(msg_buf, err_classes[i].class, len);
                 strncat(msg_buf, " - ", len - strlen(msg_buf));
-                sprintf(internal_buf, "%d", err_code);
+                snprintf(internal_buf, sizeof(internal_buf)-1, "%d", err_code);
                 strncat(msg_buf, internal_buf, len - strlen(msg_buf));
                 strncat(msg_buf, " (Unknown error code).", len - strlen(msg_buf));
 
@@ -200,7 +200,7 @@ int SMB_Get_SMB_Error_Msg(int err_class, int err_code, char *msg_buf, int len)
 
                 strncpy(msg_buf, err_classes[i].class, len);
                 strncat(msg_buf, " - ", len - strlen(msg_buf));
-                sprintf(internal_buf, "%d", err_code);
+                snprintf(internal_buf, sizeof(internal_buf)-1, "%d", err_code);
                 strncat(msg_buf, internal_buf, len - strlen(msg_buf));
 
                 return(strlen(msg_buf));
@@ -211,10 +211,10 @@ int SMB_Get_SMB_Error_Msg(int err_class, int err_code, char *msg_buf, int len)
 
     /* If we get here, we did not recognize the error class */
 
-    sprintf(internal_buf, "%d", err_class);
+    snprintf(internal_buf, sizeof(internal_buf)-1, "%d", err_class);
     strncat(msg_buf, internal_buf, len - strlen(msg_buf));
     strncat(msg_buf, " (Unknown Error Class) - ", len - strlen(msg_buf));
-    sprintf(internal_buf, "%d", err_code);
+    snprintf(internal_buf, sizeof(internal_buf)-1, "%d", err_code);
     strncat(msg_buf, internal_buf, len - strlen(msg_buf));
     strncat(msg_buf, "(error code).", len - strlen(msg_buf));
 
index 72c250a00bb4f3344d091c28cd1fa6d256d2d9ce..97f7c7b4856cbc003545a998554d3ef024adabe6 100755 (executable)
@@ -107,13 +107,14 @@ for FILENAME in `ls -1`; do
 
        #
        # detect functions unsafe for use within Squid.
-       # strdup()
+       # strdup() - only allowed in compat/xstring.h which defines a safe replacement.
+       # sprintf() - not allowed anywhere.
        #
-       STRDUP=`grep -e "[^x]strdup" ${FILENAME}`;
-       if test "x${STRDUP}" != "x" ; then
+       STRDUP=`grep -e "[^x]strdup(" ${FILENAME}`;
+       if test "x${STRDUP}" != "x" -a "${FILENAME}" != "xstring.h"; then
                echo "ERROR: ${PWD}/${FILENAME} contains unprotected use of strdup()"
        fi
-       SPRINTF=`grep -e "[^v]sprintf" ${FILENAME}`;
+       SPRINTF=`grep -e "[^v]sprintf(" ${FILENAME}`;
        if test "x${SPRINTF}" != "x" ; then
                echo "ERROR: ${PWD}/${FILENAME} contains unsafe use of sprintf()"
        fi
index 06ef4231e5bf6eebc83919afbfe33004d069febe..c8c2c99724d3a62cc731c2693f680becd5d93fa7 100644 (file)
 
 CBDATA_CLASS_INIT(BlockingFile);
 
-BlockingFile::BlockingFile(char const *aPath) : fd (-1), closed (true), error_(false)
+BlockingFile::BlockingFile(char const *aPath) : fd(-1), closed(true), error_(false)
 {
     assert(aPath);
     debugs(79, 3, "BlockingFile::BlockingFile: " << aPath);
-    path_ = xstrdup (aPath);
+    path_ = xstrdup(aPath);
 }
 
 BlockingFile::~BlockingFile()
 {
-    safe_free (path_);
+    safe_free(path_);
     doClose();
 }
 
index b3e5e57bad93dd9e30f9791b780c5d1360dd83e1..09100de97ef995467bc7a764b055ee54c4681f50 100644 (file)
@@ -59,16 +59,16 @@ DiskdFile::DiskdFile(char const *aPath, DiskdIOStrategy *anIO) :
         mode(0),
         inProgressIOs(0)
 {
-    assert (aPath);
+    assert(aPath);
     debugs(79, 3, "DiskdFile::DiskdFile: " << aPath);
-    path_ = xstrdup (aPath);
+    path_ = xstrdup(aPath);
     id = diskd_stats.sio_id;
     ++diskd_stats.sio_id;
 }
 
 DiskdFile::~DiskdFile()
 {
-    assert (inProgressIOs == 0);
+    assert(inProgressIOs == 0);
     safe_free (path_);
 }
 
@@ -76,9 +76,9 @@ void
 DiskdFile::open(int flags, mode_t aMode, RefCount< IORequestor > callback)
 {
     debugs(79, 3, "DiskdFile::open: " << this << " opening for " << callback.getRaw());
-    assert (ioRequestor.getRaw() == NULL);
+    assert(ioRequestor.getRaw() == NULL);
     ioRequestor = callback;
-    assert (callback.getRaw());
+    assert(callback.getRaw());
     mode = flags;
     ssize_t shm_offset;
     char *buf = (char *)IO->shm.get(&shm_offset);
index fe7a59c28694be97425fc832bf0e67099c2d5854..3ee452e34ece6c4c425f5967bc4c9eebefe8d5cb 100644 (file)
@@ -54,14 +54,14 @@ CBDATA_CLASS_INIT(DiskThreadsDiskFile);
 DiskThreadsDiskFile::DiskThreadsDiskFile(char const *aPath, DiskThreadsIOStrategy *anIO):fd(-1), errorOccured (false), IO(anIO),
         inProgressIOs (0)
 {
-    assert (aPath);
+    assert(aPath);
     debugs(79, 3, "UFSFile::UFSFile: " << aPath);
-    path_ = xstrdup (aPath);
+    path_ = xstrdup(aPath);
 }
 
 DiskThreadsDiskFile::~DiskThreadsDiskFile()
 {
-    safe_free (path_);
+    safe_free(path_);
     doClose();
 }
 
index 8c34b075f3147918aa31838e57d71904b63c2780..8e764d1b31fe1a9b40617be0b7ded443c23088ad 100644 (file)
@@ -11,7 +11,7 @@ class SBufEqual
 {
 public:
     explicit SBufEqual(const SBuf &reference, SBufCaseSensitive sensitivity = caseSensitive) :
-        reference_(reference), sensitivity_(sensitivity) {}
+            reference_(reference), sensitivity_(sensitivity) {}
     bool operator() (const SBuf & checking) { return checking.compare(reference_,sensitivity_) == 0; }
 private:
     SBuf reference_;
@@ -23,7 +23,7 @@ class SBufStartsWith
 {
 public:
     explicit SBufStartsWith(const SBuf &prefix, SBufCaseSensitive sensitivity = caseSensitive) :
-        prefix_(prefix), sensitivity_(sensitivity) {}
+            prefix_(prefix), sensitivity_(sensitivity) {}
     bool operator() (const SBuf & checking) { return checking.startsWith(prefix_,sensitivity_); }
 private:
     SBuf prefix_;
@@ -38,7 +38,7 @@ class SBufAddLength
 {
 public:
     explicit SBufAddLength(const SBuf &separator) :
-        separatorLen_(separator.length()) {}
+            separatorLen_(separator.length()) {}
     SBuf::size_type operator()(const SBuf::size_type sz, const SBuf & item) {
         return sz + item.length() + separatorLen_;
     }
@@ -68,7 +68,7 @@ SBufContainerJoin(const Container &items, const SBuf& separator)
     typename Container::const_iterator i(items.begin());
     rv.append(*i);
     ++i;
-    for (;i != items.end(); ++i)
+    for (; i != items.end(); ++i)
         rv.append(separator).append(*i);
     return rv;
 }
index 52dec38828a8105f1b981a8186366aff45d9d9b2..0ba27cd57ab0bef41ba78f6d24def3c33e21f449 100644 (file)
 static StatHist sbufDestructTimeStats;
 static StatHist memblobDestructTimeStats;
 
-namespace SBufDetailedStatsHistInitializer {
-    // run the post-instantiation initialization methods for StatHist objects
-    struct Initializer
-    {
-        Initializer() {
-            sbufDestructTimeStats.logInit(300,30.0,128000.0);
-            memblobDestructTimeStats.logInit(300,30.0,128000.0);
-        }
-    };
-    Initializer initializer;
+namespace SBufDetailedStatsHistInitializer
+{
+// run the post-instantiation initialization methods for StatHist objects
+struct Initializer {
+    Initializer() {
+        sbufDestructTimeStats.logInit(300,30.0,128000.0);
+        memblobDestructTimeStats.logInit(300,30.0,128000.0);
+    }
+};
+Initializer initializer;
 }
 
 void
index 2484dd67a28af619d0e4c224f1a421cd988f7b0e..d585d015aae5858495c17a4e35086101dde0c4d7 100644 (file)
@@ -67,8 +67,8 @@ SBufStatsAction::dump(StoreEntry* entry)
 {
     StoreEntryStream ses(entry);
     ses << "\n\n\nThese statistics are experimental; their format and contents "
-        "should not be relied upon, they are bound to change as "
-        "the SBuf feature is evolved\n";
+    "should not be relied upon, they are bound to change as "
+    "the SBuf feature is evolved\n";
     sbdata.dump(ses);
     mbdata.dump(ses);
     ses << "\n";
index d3ed5edf726981acb400ae716a6d8ef38bc409bb..16c027d0d366b14540a8c1938e23469ec331e72c 100644 (file)
@@ -59,7 +59,7 @@ ACLCertificateData::ACLCertificateData(ACLCertificateData const &old) : attribut
     validAttributes.assign (old.validAttributes.begin(), old.validAttributes.end());
     attributeIsOptional = old.attributeIsOptional;
     if (old.attribute)
-        attribute = xstrdup (old.attribute);
+        attribute = xstrdup(old.attribute);
 }
 
 template<class T>
index c96dcf0e47fc3447e067535ff6ac02cc1e08145f..4c104f249f52a56a9ca450f7398b05309ddd5511 100644 (file)
@@ -53,7 +53,6 @@
 #include <set>
 #include <algorithm>
 
-
 typedef std::set<ACL*> AclSet;
 /// Accumulates all ACLs to facilitate their clean deletion despite reuse.
 static AclSet *RegisteredAcls; // TODO: Remove when ACLs are refcounted
index 13728e57d9b5578f501ff3d6e91369eb5e83d48b..3a931a832481bf9574500181c03c1a9feb0eee01 100644 (file)
@@ -1,8 +1,8 @@
 #ifndef SQUID_ADAPTATION__ACCESS_CHECK_H
 #define SQUID_ADAPTATION__ACCESS_CHECK_H
 
-#include "acl/Acl.h"
 #include "AccessLogEntry.h"
+#include "acl/Acl.h"
 #include "adaptation/Elements.h"
 #include "adaptation/forward.h"
 #include "adaptation/Initiator.h"
index add249c06537d5aed9f9033bae49f64c8eee3c0e..42f0d9e7ddd0c3d75b3f9b23054970bef2e0c579 100644 (file)
@@ -78,7 +78,7 @@ EssentialVersion(const SBuf &raw)
     // everything after the second period
     const SBuf::size_type minorPos = raw.find('.');
     const SBuf::size_type microPos = minorPos == SBuf::npos ?
-        SBuf::npos : raw.find('.', minorPos+1);
+                                     SBuf::npos : raw.find('.', minorPos+1);
     return raw.substr(0, microPos); // becomes raw if microPos is npos
 }
 
index 9c78a45012435ff81916a32d9c526e8ea8b50a69..bf0a7bb56c9b3d701dbd26e246729878d47c919d 100644 (file)
@@ -2,14 +2,14 @@
  * DEBUG: section 93    eCAP Interface
  */
 #include "squid.h"
-#include "Debug.h"
-#include "EventLoop.h"
 #include "adaptation/ecap/Config.h"
 #include "adaptation/ecap/Host.h"
 #include "adaptation/ecap/ServiceRep.h"
 #include "adaptation/ecap/XactionRep.h"
 #include "AsyncEngine.h"
 #include "base/TextException.h"
+#include "Debug.h"
+#include "EventLoop.h"
 
 #include <libecap/adapter/service.h>
 #include <libecap/common/options.h>
@@ -105,7 +105,7 @@ Adaptation::Ecap::Engine::checkEvents(int)
     // Start with the default I/O loop timeout, convert from milliseconds.
     static const struct timeval maxTimeout {
         EVENT_LOOP_TIMEOUT/1000, // seconds
-        (EVENT_LOOP_TIMEOUT % 1000)*1000 
+        (EVENT_LOOP_TIMEOUT % 1000)*1000
     }; // microseconds
     struct timeval timeout = maxTimeout;
 
index 43af041f2cd715f9294dd65d853f0f69c7eef715..9e674dcf0dc299a6f42d7e6d98b3685af1ecfc60 100644 (file)
@@ -25,7 +25,7 @@ ACLMaxUserIP::ACLMaxUserIP(ACLMaxUserIP const &old) :
         class_(old.class_),
         maximum(old.maximum)
 {
-   flags = old.flags;
+    flags = old.flags;
 }
 
 ACLMaxUserIP::~ACLMaxUserIP()
index dba69a7db633d151eafadb641d0c77c38b37915e..52fc73a0fcfa94519b5177e8762cd7862e542bdd 100644 (file)
@@ -105,10 +105,10 @@ Auth::Config::parse(Auth::Config * scheme, int n_configured, char *param_str)
             delete keyExtras;
 
         keyExtras = nlf;
-        
+
         if (char *t = strtok(NULL, w_space)) {
-               debugs(29, DBG_CRITICAL, "FATAL: Unexpected argument '" << t << "' after request_format specification");
-               self_destruct();
+            debugs(29, DBG_CRITICAL, "FATAL: Unexpected argument '" << t << "' after request_format specification");
+            self_destruct();
         }
     } else {
         debugs(29, DBG_CRITICAL, "Unrecognised " << scheme->type() << " auth scheme parameter '" << param_str << "'");
@@ -126,6 +126,6 @@ void
 Auth::Config::done()
 {
     delete keyExtras;
-    keyExtras = NULL; 
+    keyExtras = NULL;
     keyExtrasLine.clean();
 }
index 6f1c981a415b5139b7037905e7ee758fbd00e495..d3cb095c329d09b9287b33a3b6906c5c942c2acc 100644 (file)
@@ -46,7 +46,7 @@ class wordlist;
 
 namespace Format
 {
-    class Format;
+class Format;
 }
 
 namespace Auth
index 5315c7cb4b6941eed6327ba0d086977cacbe6592..e9359acfc79fca9400963b909387977908e9e78a 100644 (file)
@@ -41,9 +41,9 @@
 #include "auth/UserRequest.h"
 #include "client_side.h"
 #include "comm/Connection.h"
+#include "format/Format.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
-#include "format/Format.h"
 #include "MemBuf.h"
 
 /* Generic Functions */
index a9f6305ec70311b0d90c495dadc016f13f0923e1..aaebbd5de2f8edca841e547c5611e0056fd3f1c6 100644 (file)
@@ -6,10 +6,10 @@
 #include "auth/State.h"
 #include "charset.h"
 #include "Debug.h"
+#include "format/Format.h"
 #include "HelperReply.h"
 #include "HttpMsg.h"
 #include "HttpRequest.h"
-#include "format/Format.h"
 #include "MemBuf.h"
 #include "rfc1738.h"
 #include "SquidTime.h"
index 8b47206a1999143247fe99438f75c7ca2462bfe6..6d00950c9c82887c740028b2ef5adcb6890d890c 100644 (file)
@@ -289,7 +289,6 @@ Auth::Basic::Config::decode(char const *proxy_auth, const char *aRequestRealm)
         Tolower(cleartext);
     local_basic->username(cleartext);
 
-
     if (local_basic->passwd == NULL) {
         debugs(29, 4, HERE << "no password in proxy authorization header '" << proxy_auth << "'");
         auth_user_request->setDenyMessage("no password was present in the HTTP [proxy-]authorization header. This is most likely a browser bug");
index 0a4e9452ee504b801d814310c6b37070a2947223..3a199f0046e05ebf4aa1e3a80f2cf5f0db6005aa 100644 (file)
@@ -5,10 +5,10 @@
 #include "auth/digest/UserRequest.h"
 #include "auth/State.h"
 #include "charset.h"
+#include "format/Format.h"
 #include "HttpHeaderTools.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
-#include "format/Format.h"
 #include "MemBuf.h"
 #include "SquidTime.h"
 
index ed34ff2d63a84dc1735320775355dea37779b9e8..ee33419bfa3d6364658c3f1f64fe544c2e46707c 100644 (file)
@@ -5,12 +5,12 @@
 #include "auth/State.h"
 #include "auth/User.h"
 #include "client_side.h"
+#include "format/Format.h"
 #include "globals.h"
 #include "helper.h"
 #include "HttpHeaderTools.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
-#include "format/Format.h"
 #include "MemBuf.h"
 #include "SquidTime.h"
 
index 9c6d58c9ee37854d502c61f498e151d52d79565f..0f79d5b98f3ff6f4d107cad885edf65a14f8ddcf 100644 (file)
@@ -5,10 +5,10 @@
 #include "auth/State.h"
 #include "cbdata.h"
 #include "client_side.h"
+#include "format/Format.h"
 #include "globals.h"
 #include "HttpMsg.h"
 #include "HttpRequest.h"
-#include "format/Format.h"
 #include "MemBuf.h"
 #include "SquidTime.h"
 
index 563dabb9aca3d248401d1bf0e308536c594bee79..920253415798aabda5b16233e0af12b1f07e3e10 100644 (file)
@@ -41,16 +41,18 @@ CharacterSet::addRange(unsigned char low, unsigned char high)
     return *this;
 }
 
-CharacterSet::CharacterSet(const char *label, const char * const c)
-: name(label == NULL ? "anonymous" : label), chars_(Storage(256,0))
+CharacterSet::CharacterSet(const char *label, const char * const c) :
+        name(label == NULL ? "anonymous" : label),
+        chars_(Storage(256,0))
 {
     const size_t clen = strlen(c);
     for (size_t i = 0; i < clen; ++i)
         add(c[i]);
 }
 
-CharacterSet::CharacterSet(const char *label, unsigned char low, unsigned char high)
-: name(label == NULL ? "anonymous" : label), chars_(Storage(256,0))
+CharacterSet::CharacterSet(const char *label, unsigned char low, unsigned char high) :
+        name(label == NULL ? "anonymous" : label),
+        chars_(Storage(256,0))
 {
     addRange(low,high);
 }
index 9388003c571d07827cdec1e86e3303c92047fdd1..4ab86b32fe3da7d6582adc66e2a9fb5d6e457925 100644 (file)
@@ -76,7 +76,7 @@ private:
      *  constructor. This assumption is relied upon in operator[], add,
      *  operator+=
      */
-   Storage chars_;
+    Storage chars_;
 };
 
 #endif /* _SQUID_SRC_PARSER_CHARACTERSET_H */
index 62ceb4cc1a80c4d180c2359f55d448fdb36814d6..87ab1b2a338231de5f41e979d3ffc91ec54c0bd0 100644 (file)
@@ -123,8 +123,8 @@ clientdbInit(void)
 
 class ClientDbRr: public RegisteredRunner
 {
-    public:
-        virtual void run(const RunnerRegistry &);
+public:
+    virtual void run(const RunnerRegistry &);
 };
 RunnerRegistrationEntry(rrAfterConfig, ClientDbRr);
 
index 9fbf9e52a2282ebfc5666cebbb75430afe58c89e..dcaa0a6811cdfe982c8dece7fa506a029e9a9f01 100644 (file)
@@ -1783,7 +1783,7 @@ ClientSocketContext::pullData()
 }
 
 /** Adapt stream status to account for Range cases
- * 
+ *
  */
 clientStream_status_t
 ClientSocketContext::socketState()
@@ -1817,7 +1817,7 @@ ClientSocketContext::socketState()
 
             if (bytesSent == bytesExpected) // got everything
                 return STREAM_COMPLETE;
-            
+
             if (bytesSent > bytesExpected) // Error: Sent more than expected
                 return STREAM_UNPLANNED_COMPLETE;
         }
index 870c33bd168e2aa9a2508455f9b33ec9921a913b..32abb96e39fc121673c5e646f19df9ecec69f2b9 100644 (file)
@@ -108,7 +108,7 @@ void
 ESIContext::setErrorMessage(char const *anError)
 {
     if (!errormessage)
-        errormessage = xstrdup (anError);
+        errormessage = xstrdup(anError);
 }
 
 #endif /* USE_SQUID_ESI == 1 */
index 120f71beff14a7233279b77d42c07f71fb908523..7d3f8bfe3380a18c0d1ed619be06b061febbde16 100644 (file)
@@ -295,10 +295,10 @@ ESIInclude::ESIInclude(ESIInclude const &old) :
     flags.onerrorcontinue = old.flags.onerrorcontinue;
 
     if (old.srcurl)
-        srcurl = xstrdup (old.srcurl);
+        srcurl = xstrdup(old.srcurl);
 
     if (old.alturl)
-        alturl = xstrdup (old.alturl);
+        alturl = xstrdup(old.alturl);
 }
 
 void
@@ -353,7 +353,7 @@ ESIInclude::ESIInclude(esiTreeParentPtr aParent, int attrcount, char const **att
             assert (src.getRaw() == NULL);
             src = ESIStreamContextNew (this);
             assert (src.getRaw() != NULL);
-            srcurl = xstrdup ( attr[i+1]);
+            srcurl = xstrdup(attr[i+1]);
         } else if (!strcmp(attr[i],"alt")) {
             /* Start a secondary request for thisNode url */
             /* TODO: make a config parameter to wait on requesting alt's
@@ -364,7 +364,7 @@ ESIInclude::ESIInclude(esiTreeParentPtr aParent, int attrcount, char const **att
             assert (alt.getRaw() == NULL); /* TODO: FIXME */
             alt = ESIStreamContextNew (this);
             assert (alt.getRaw() != NULL);
-            alturl = xstrdup (attr[i+1]);
+            alturl = xstrdup(attr[i+1]);
         } else if (!strcmp(attr[i],"onerror")) {
             if (!strcmp(attr[i+1], "continue")) {
                 flags.onerrorcontinue = 1;
index f43e5b0de2b5693ba9057bbf240e03e1bc3b1dfb..13e4f73109177c2ba95c59452f1c37c328b0532b 100644 (file)
@@ -202,14 +202,14 @@ ESIVariableUserAgent::getProductVersion (char const *s)
 {
     char const *t;
     int len;
-    t = index (s,'/');
+    t = index(s,'/');
 
     if (!t || !*(++t))
-        return xstrdup ("");
+        return xstrdup("");
 
-    len = strcspn (t, " \r\n()<>@,;:\\\"/[]?={}");
+    len = strcspn(t, " \r\n()<>@,;:\\\"/[]?={}");
 
-    return xstrndup (t, len + 1);
+    return xstrndup(t, len + 1);
 }
 
 ESIVariableQuery::ESIVariableQuery(char const *uri) : query (NULL), query_sz (0), query_elements (0), query_string (NULL)
@@ -219,11 +219,11 @@ ESIVariableQuery::ESIVariableQuery(char const *uri) : query (NULL), query_sz (0)
 
     if (query_start && query_start[1] != '\0' ) {
         unsigned int n;
-        query_string = xstrdup (query_start + 1);
+        query_string = xstrdup(query_start + 1);
         query_elements = 1;
         char const *query_pos = query_start + 1;
 
-        while ((query_pos = strchr (query_pos, '&'))) {
+        while ((query_pos = strchr(query_pos, '&'))) {
             ++query_elements;
             ++query_pos;
         }
@@ -234,8 +234,8 @@ ESIVariableQuery::ESIVariableQuery(char const *uri) : query (NULL), query_sz (0)
         n = 0;
 
         while (query_pos) {
-            char const *next = strchr (query_pos, '&');
-            char const *div = strchr (query_pos, '=');
+            char const *next = strchr(query_pos, '&');
+            char const *div = strchr(query_pos, '=');
 
             if (next)
                 ++next;
@@ -249,19 +249,19 @@ ESIVariableQuery::ESIVariableQuery(char const *uri) : query (NULL), query_sz (0)
                 /* zero length between & and = or & and & */
                 continue;
 
-            query[n].var = xstrndup (query_pos, div - query_pos + 1) ;
+            query[n].var = xstrndup(query_pos, div - query_pos + 1) ;
 
             if (div == next) {
-                query[n].val = xstrdup ("");
+                query[n].val = xstrdup("");
             } else {
-                query[n].val = xstrndup (div + 1, next - div - 1);
+                query[n].val = xstrndup(div + 1, next - div - 1);
             }
 
             query_pos = next;
             ++n;
         }
     } else {
-        query_string = xstrdup ("");
+        query_string = xstrdup("");
     }
 
     if (query) {
@@ -383,14 +383,14 @@ ESIVariableUserAgent::ESIVariableUserAgent(ESIVarState &state)
             t = index (t, ' ');
 
             if (!t)
-                browserversion = xstrdup ("");
+                browserversion = xstrdup("");
             else {
-                t1 = index (t, ';');
+                t1 = index(t, ';');
 
                 if (!t1)
-                    browserversion = xstrdup (t + 1);
+                    browserversion = xstrdup(t + 1);
                 else
-                    browserversion = xstrndup (t + 1, t1-t);
+                    browserversion = xstrndup(t + 1, t1-t);
             }
         } else if (strstr (s, "Mozilla")) {
             browser = ESI_BROWSER_MOZILLA;
@@ -402,7 +402,7 @@ ESIVariableUserAgent::ESIVariableUserAgent(ESIVarState &state)
     } else {
         UserOs = ESI_OS_OTHER;
         browser = ESI_BROWSER_OTHER;
-        browserversion = xstrdup ("");
+        browserversion = xstrdup("");
     }
 }
 
index 8e858aaedd783bb2708ffab48cab87bba50f3a60..95e8a73f9f4df46b8194e867e94e47b48b748dc4 100644 (file)
@@ -1636,13 +1636,13 @@ ACLExternal::clone() const
     return new ACLExternal(*this);
 }
 
-ACLExternal::ACLExternal (char const *theClass) : data (NULL), class_ (xstrdup (theClass))
+ACLExternal::ACLExternal(char const *theClass) : data(NULL), class_(xstrdup(theClass))
 {}
 
-ACLExternal::ACLExternal (ACLExternal const & old) : data (NULL), class_ (old.class_ ? xstrdup (old.class_) : NULL)
+ACLExternal::ACLExternal(ACLExternal const & old) : data(NULL), class_(old.class_ ? xstrdup(old.class_) : NULL)
 {
     /* we don't have copy constructors for the data yet */
-    assert (!old.data);
+    assert(!old.data);
 }
 
 char const *
index dee57681ae92f5491c37d646bb64d268c5665eeb..b90f597e3310bfce07572ed7e086a7349e3e223b 100644 (file)
@@ -496,7 +496,7 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS
         break;
 
         case LFT_TIME_START: {
-            int precision = fmt->widthMax >=0 ? fmt->widthMax : 3;
+            int precision = fmt->widthMax >=0 ? fmt->widthMax :3;
             snprintf(tmp, sizeof(tmp), "%0*" PRId64 ".%0*d", fmt->zero && (fmt->widthMin - precision - 1 >= 0) ? fmt->widthMin - precision - 1 : 0, static_cast<int64_t>(al->cache.start_time.tv_sec), precision, (int)(al->cache.start_time.tv_usec / fmt->divisor));
             out = tmp;
         }
index 6f1317d573ac1264471d77fba5370a35a58fd48a..a51090f63e1ff28d7f360a8e5f9c6cd860cb6299 100644 (file)
@@ -501,21 +501,15 @@ doV2Query(int fd, Ip::Address &from, char *buf, icp_common_t header)
 #endif /* USE_ICMP */
 
     /* The peer is allowed to use this cache */
-    ICP2State *state = new ICP2State (header, icp_request);
-
+    ICP2State *state = new ICP2State(header, icp_request);
     state->fd = fd;
-
     state->from = from;
-
-    state->url = xstrdup (url);
-
+    state->url = xstrdup(url);
     state->flags = flags;
-
     state->rtt = rtt;
-
     state->src_rtt = src_rtt;
 
-    StoreEntry::getPublic (state, url, Http::METHOD_GET);
+    StoreEntry::getPublic(state, url, Http::METHOD_GET);
 
     HTTPMSGUNLOCK(icp_request);
 }
index 41f87ab6f08f3ed37139c908ee9d19762858c0db..33bd839477787c4469b830c89c1097ba38006b35 100644 (file)
@@ -58,7 +58,7 @@ doV3Query(int fd, Ip::Address &from, char *buf, icp_common_t header)
 {
     /* We have a valid packet */
     char *url = buf + sizeof(icp_common_t) + sizeof(uint32_t);
-    HttpRequest *icp_request = icpGetRequest (url, header.reqnum, fd, from);
+    HttpRequest *icp_request = icpGetRequest(url, header.reqnum, fd, from);
 
     if (!icp_request)
         return;
@@ -71,12 +71,9 @@ doV3Query(int fd, Ip::Address &from, char *buf, icp_common_t header)
 
     /* The peer is allowed to use this cache */
     ICP3State *state = new ICP3State (header, icp_request);
-
     state->fd = fd;
-
     state->from = from;
-
-    state->url = xstrdup (url);
+    state->url = xstrdup(url);
 
     StoreEntry::getPublic (state, url, Http::METHOD_GET);
 }
index 1b6a6a3665bc2b1f3f267b77c123b88d981e46e9..f5d45357f46139656b5004aded9a623df363472e 100644 (file)
@@ -237,7 +237,7 @@ hash_key(const unsigned char *data, unsigned int len, unsigned int hashSize)
 {
     unsigned int n;
     unsigned int j;
-    for(j = 0, n = 0; j < len; j++ ) {
+    for (j = 0, n = 0; j < len; j++ ) {
         n ^= 271 * *data;
         ++data;
     }
@@ -311,7 +311,7 @@ Ipc::MemMapSlot::empty() const
 /* Ipc::MemMap::Shared */
 
 Ipc::MemMap::Shared::Shared(const int aLimit, const size_t anExtrasSize):
-    limit(aLimit), extrasSize(anExtrasSize), count(0), slots(aLimit)
+        limit(aLimit), extrasSize(anExtrasSize), count(0), slots(aLimit)
 {
 }
 
index d86a4aa284c659c92f4a79c4dfee836e9cd5b7e8..4f24301a11545e8499b5a4f1031a928e053b8a77 100644 (file)
@@ -223,7 +223,7 @@ refreshStaleness(const StoreEntry * entry, time_t check_time, const time_t age,
         time_t stale_age = static_cast<time_t>(lastmod_delta * R->pct);
 
         debugs(22,3, "Last modified " << lastmod_delta << " sec before we cached it, L-M factor " <<
-                     (100.0 * R->pct) << "% = " << stale_age << " sec freshness lifetime");
+               (100.0 * R->pct) << "% = " << stale_age << " sec freshness lifetime");
         sf->lmfactor = true;
 
         if (age >= stale_age) {
index f730e03c82eeda8f7f81948a8aa20b2db0667a3a..32dd1f3ecdf8c9698bba7a6f1f1c687766e0a789 100644 (file)
@@ -5,10 +5,10 @@ Ssl::Config Ssl::TheConfig;
 
 Ssl::Config::Config():
 #if USE_SSL_CRTD
-            ssl_crtd(NULL),
+        ssl_crtd(NULL),
 #endif
-            ssl_crt_validator(NULL)
-{ 
+        ssl_crt_validator(NULL)
+{
     ssl_crt_validator_Children.concurrency = 1;
 }
 
index 997d70281e47a4c9ef518d6f2661897371ac0da7..719fe103d7b464f286f18d5b74abb9d99d30544e 100644 (file)
@@ -41,8 +41,8 @@
 #include "acl/FilledChecklist.h"
 #include "anyp/PortCfg.h"
 #include "fde.h"
-#include "ipc/MemMap.h"
 #include "globals.h"
+#include "ipc/MemMap.h"
 #include "SquidConfig.h"
 #include "SquidTime.h"
 #include "ssl/Config.h"
@@ -1694,7 +1694,7 @@ store_session_cb(SSL *ssl, SSL_SESSION *session)
     unsigned int idlen = session->session_id_length;
     unsigned char key[MEMMAP_SLOT_KEY_SIZE];
     // Session ids are of size 32bytes. They should always fit to a
-    // MemMap::Slot::key 
+    // MemMap::Slot::key
     assert(idlen <= MEMMAP_SLOT_KEY_SIZE);
     memset(key, 0, sizeof(key));
     memcpy(key, id, idlen);
@@ -1803,7 +1803,7 @@ Ssl::initialize_session_cache()
     if (!isSslServer()) //no need to configure ssl session cache.
         return;
 
-    // Check if the MemMap keys and data are enough big to hold 
+    // Check if the MemMap keys and data are enough big to hold
     // session ids and session data
     assert(SSL_SESSION_ID_SIZE >= MEMMAP_SLOT_KEY_SIZE);
     assert(SSL_SESSION_MAX_SIZE >= MEMMAP_SLOT_DATA_SIZE);
index b01b39344b3b1ec7cde205987cc39a7d86e2103c..36f7b1e4937b8cdcb2450a4947cb50708489909e 100644 (file)
@@ -1,9 +1,11 @@
 STUB_SOURCE= tests/STUB.h \
        tests/stub_CacheDigest.cc \
+       tests/stub_CollapsedForwarding.cc \
        tests/stub_CommIO.cc \
        tests/stub_DelayId.cc \
        tests/stub_DiskIOModule.cc \
        tests/stub_ETag.cc \
+       tests/stub_EventLoop.cc \
        tests/stub_HelperChildConfig.cc \
        tests/stub_HttpReply.cc \
        tests/stub_HttpRequest.cc \
@@ -11,6 +13,7 @@ STUB_SOURCE= tests/STUB.h \
        tests/stub_MemObject.cc \
        tests/stub_MemStore.cc \
        tests/stub_Port.cc \
+       tests/stub_SBufDetailedStats.cc \
        tests/stub_StatHist.cc \
        tests/stub_StoreMeta.cc \
        tests/stub_SwapDir.cc \
index 228f4db3ce78e9c9522e68ac6940ef71d114ac3a..4f4626da43673c7967eac76569579f39878208c9 100644 (file)
@@ -10,4 +10,4 @@ EventLoop::EventLoop(): errcount(0), last_loop(false), timeService(NULL),
         primaryEngine(NULL), loop_delay(0), error(false), runOnceResult(false)
         STUB_NOP
 
-void EventLoop::registerEngine(AsyncEngine *engine) STUB
+        void EventLoop::registerEngine(AsyncEngine *engine) STUB
index 85e871dae5ddcfae41fa2466aa995605c39ca713..40b3d148b56871cef9f9393f089c3608b6ab1137 100644 (file)
@@ -12,9 +12,9 @@
 #include "ssl/Config.h"
 Ssl::Config::Config():
 #if USE_SSL_CRTD
-            ssl_crtd(NULL),
+        ssl_crtd(NULL),
 #endif
-            ssl_crt_validator(NULL)
+        ssl_crt_validator(NULL)
 {
     ssl_crt_validator_Children.concurrency = 1;
     STUB_NOP
index 3b2e640f7ef53a468cd2c8d9d4ef1306367d3803..da9b757cd53be3961268b2d1c9ae7c8072539e77 100644 (file)
@@ -117,17 +117,13 @@ testRock::commonInit()
     StoreFileSystem::SetupAllFs();
 
     Config.Store.avgObjectSize = 1024;
-
     Config.Store.objectsPerBucket = 20;
-
     Config.Store.maxObjectSize = 2048;
 
     Config.store_dir_select_algorithm = xstrdup("round-robin");
 
     Config.replPolicy = new RemovalPolicySettings;
-
-    Config.replPolicy->type = xstrdup ("lru");
-
+    Config.replPolicy->type = xstrdup("lru");
     Config.replPolicy->args = NULL;
 
     /* garh garh */
index 7cf1f05d1c2a38b85bea013fd785d74302ba7221..8cf5e7b1d3211370917f7e0efcb3c4bffbb4362d 100644 (file)
@@ -799,7 +799,6 @@ testSBuf::testFindFirstNotOf()
     CPPUNIT_ASSERT_EQUAL(3U,idx);
 }
 
-
 void
 testSBuf::testAutoFind()
 {
index 45fb28be003dcfdad51b2561e9e7e36239dd6293..84c89fa393d322e81bf5bbd5ffd099d7ab2ac21e 100644 (file)
@@ -53,16 +53,13 @@ testUfs::commonInit()
         return;
 
     Config.Store.avgObjectSize = 1024;
-
     Config.Store.objectsPerBucket = 20;
-
     Config.Store.maxObjectSize = 2048;
 
     Config.store_dir_select_algorithm = xstrdup("round-robin");
 
     Config.replPolicy = new RemovalPolicySettings;
-
-    Config.replPolicy->type = xstrdup ("lru");
+    Config.replPolicy->type = xstrdup("lru");
 
     /* garh garh */
     storeReplAdd("lru", createRemovalPolicy_lru);
@@ -240,7 +237,7 @@ testUfs::testUfsDefaultEngine()
     addSwapDir(aStore);
     commonInit();
     Config.replPolicy = new RemovalPolicySettings;
-    Config.replPolicy->type = xstrdup ("lru");
+    Config.replPolicy->type = xstrdup("lru");
     mem_policy = createRemovalPolicy(Config.replPolicy);
 
     char *path=xstrdup(TESTDIR);
index d888770b51366605ecb1ac0dd31f89d41516d2f2..b907d7ca37c8380065c0b335760b690073c4a75f 100644 (file)
@@ -190,9 +190,9 @@ UrnState::createUriResRequest (String &uri)
     char *host = getHost (uri);
     snprintf(local_urlres, 4096, "http://%s/uri-res/N2L?urn:" SQUIDSTRINGPH,
              host, SQUIDSTRINGPRINT(uri));
-    safe_free (host);
-    safe_free (urlres);
-    urlres = xstrdup (local_urlres);
+    safe_free(host);
+    safe_free(urlres);
+    urlres = xstrdup(local_urlres);
     urlres_r = HttpRequest::CreateFromUrl(urlres);
 }
 
index 19e495301de14970c8bc8b65ce3d6d4fdc3de98f..d35410a0eceb39eff905ddbff6a3c898666984d3 100644 (file)
@@ -98,7 +98,7 @@ main(int argc, char **argv)
             run_stats = atoi(optarg);
             break;
         case 'f':
-            fn = strdup(optarg);
+            fn = xstrdup(optarg);
             fp = fopen(fn, "r");
             break;
         case 'i':
@@ -291,7 +291,7 @@ const char *
 make_nam(int id, int size)
 {
     const char *buf = malloc(30);      /* argh */
-    sprintf((char *) buf, "pl:%d/%d", id, size);
+    snprintf((char *)buf, sizeof(buf)-1, "pl:%d/%d", id, size);
     return buf;
 }
 
index aed81722109ec7b2a0367106c1c3b3a8cccd675c..3551ef104630ae4e4d48b3640d1a9dc91062cc5d 100644 (file)
@@ -158,7 +158,7 @@ send_request(int fd, const char *data)
     struct _r *r;
     struct _r **R;
     char *method, *url, *file, *size, *checksum;
-    char *tmp = strdup(data);
+    char *tmp = xstrdup(data);
     struct stat st;
     int file_fd = -1;
     method = strtok(tmp, " ");
@@ -177,13 +177,13 @@ send_request(int fd, const char *data)
     if (checksum && strcmp(checksum, "-") == 0)
         checksum = NULL;
     msg[0] = '\0';
-    sprintf(buf, "%s %s HTTP/1.0\r\n", method, url);
+    snprintf(buf, sizeof(buf)-1, "%s %s HTTP/1.0\r\n", method, url);
     strcat(msg, buf);
     strcat(msg, "Accept: */*\r\n");
     strcat(msg, "Proxy-Connection: Keep-Alive\r\n");
     if (opt_ims && (lrand48() & 0x03) == 0) {
         w = time(NULL) - (lrand48() & 0x3FFFF);
-        sprintf(buf, "If-Modified-Since: %s\r\n", mkrfc850(&w));
+        snprintf(buf, sizeof(buf)-1, "If-Modified-Since: %s\r\n", mkrfc850(&w));
         strcat(msg, buf);
     }
     if (file) {
@@ -196,7 +196,7 @@ send_request(int fd, const char *data)
             close(file_fd);
             return -1;
         }
-        sprintf(buf, "Content-length: %d\r\n", st.st_size);
+        snprintf(buf, sizeof(buf)-1, "Content-length: %d\r\n", st.st_size);
         strcat(msg, buf);
     }
     strcat(msg, "\r\n");
@@ -557,14 +557,14 @@ char *argv[];
     int c;
     setbuf(stdout, NULL);
     setbuf(stderr, NULL);
-    progname = strdup(argv[0]);
+    progname = xstrdup(argv[0]);
     while ((c = getopt(argc, argv, "p:h:n:t:icl:r")) != -1) {
         switch (c) {
         case 'p':
             proxy_port = atoi(optarg);
             break;
         case 'h':
-            proxy_addr = strdup(optarg);
+            proxy_addr = xstrdup(optarg);
             break;
         case 'n':
             max_outstanding = atoi(optarg);
index 8de4f3b318e02a9f01bcc4009f955b86db923ea4..c43d50b6b34b18391f05b5e9b7a0afffdc2ec17e 100644 (file)
@@ -329,7 +329,7 @@ request(char *urlin) {
         checksum = "-";
     r = calloc(1, sizeof *r);
     assert(r != NULL);
-    r->url = strdup(url);
+    r->url = xstrdup(url);
     assert(r->url);
     strcpy(r->method, method);
     strcpy(r->requestbodyfile, file);
@@ -349,17 +349,17 @@ request(char *urlin) {
     } else {
         host = NULL;
     }
-    sprintf(msg, "%s %s HTTP/1.0\r\n", method, url);
+    snprintf(msg, sizeof(msg)-1, "%s %s HTTP/1.0\r\n", method, url);
     if (host) {
         url[0] = '\0';
-        sprintf(buf, "Host: %s\r\n", host);
+        snprintf(buf, sizeof(buf)-1, "Host: %s\r\n", host);
         strcat(msg, buf);
         url[0] = '/';
     }
     strcat(msg, "Accept: */*\r\n");
     if (opt_ims && (lrand48() & 0x03) == 0) {
         w = time(NULL) - (lrand48() & 0x3FFFF);
-        sprintf(buf, "If-Modified-Since: %s\r\n", mkrfc850(&w));
+        snprintf(buf, sizeof(buf)-1, "If-Modified-Since: %s\r\n", mkrfc850(&w));
         strcat(msg, buf);
     }
     if (file && strcmp(file, "-") != 0) {
@@ -369,7 +369,7 @@ request(char *urlin) {
             exit(1);
         }
         fstat(f, &st);
-        sprintf(buf, "Content-Length: %d\r\n", (int) st.st_size);
+        snprintf(buf, sizeof(buf)-1, "Content-Length: %d\r\n", (int) st.st_size);
         strcat(msg, buf);
     }
     if (opt_range && (lrand48() & 0x03) == 0) {
@@ -382,13 +382,13 @@ request(char *urlin) {
                 strcat(msg, ",");
             switch (lrand48() & 0x03) {
             case 0:
-                sprintf(buf, "-%d", len);
+                snprintf(buf, sizeof(buf)-1, "-%d", len);
                 break;
             case 1:
-                sprintf(buf, "%d-", offset);
+                snprintf(buf, sizeof(buf)-1, "%d-", offset);
                 break;
             default:
-                sprintf(buf, "%d-%d", offset, offset + len);
+                snprintf(buf, sizeof(buf)-1, "%d-%d", offset, offset + len);
                 break;
             }
             strcat(msg, buf);
@@ -480,10 +480,10 @@ char *argv[];
     struct timeval to;
     setbuf(stdout, NULL);
     setbuf(stderr, NULL);
-    progname = strdup(argv[0]);
+    progname = xstrdup(argv[0]);
     gettimeofday(&now, NULL);
     start = last = now;
-    custom_header = strdup("");
+    custom_header = xstrdup("");
     while ((c = getopt(argc, argv, "ap:h:H:n:icrl:L:t:")) != -1) {
         switch (c) {
         case 'a':
@@ -493,7 +493,7 @@ char *argv[];
             proxy_port = atoi(optarg);
             break;
         case 'h':
-            proxy_addr = strdup(optarg);
+            proxy_addr = xstrdup(optarg);
             break;
         case 'n':
             max_connections = atoi(optarg);
index 8d3fb62bd14024d609cd8353990b2769d1f489d3..69da160da05e42b44ffae15a9e95923c88134ba5 100644 (file)
@@ -139,7 +139,7 @@ readConfigFile( CacheDirVector& cachedir, const char* fn, FILE* debug )
                                       (int)subs[offset].rm_so,
                                       (int)subs[offset].rm_eo,
                                       line+subs[offset].rm_so );
-            cd.base = strdup( line+subs[offset].rm_so );
+            cd.base = xstrdup( line+subs[offset].rm_so );
             ++offset;
 
             // extract size information