#define snprintf _snprintf
#define stat _stati64
#define strcasecmp _stricmp
-#define strdup _strdup
#define strlwr _strlwr
#define strncasecmp _strnicmp
#define tempnam _tempnam
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));
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;
} 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;
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;
XPROF_storeGetMemSpace,
XPROF_storeMaintainSwapSpace,
XPROF_storeRelease,
- XPROF_storeWriteComplete,
XPROF_write,
XPROF_xcalloc,
XPROF_xmalloc,
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 */
}
- 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 ... */
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));
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));
/* 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));
#
# 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
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();
}
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_);
}
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);
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();
}
{
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_;
{
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_;
{
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_;
}
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;
}
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
{
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";
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>
#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
#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"
// 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
}
* 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>
// 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;
class_(old.class_),
maximum(old.maximum)
{
- flags = old.flags;
+ flags = old.flags;
}
ACLMaxUserIP::~ACLMaxUserIP()
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 << "'");
Auth::Config::done()
{
delete keyExtras;
- keyExtras = NULL;
+ keyExtras = NULL;
keyExtrasLine.clean();
}
namespace Format
{
- class Format;
+class Format;
}
namespace Auth
#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 */
#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"
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");
#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"
#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"
#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"
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);
}
* constructor. This assumption is relied upon in operator[], add,
* operator+=
*/
- Storage chars_;
+ Storage chars_;
};
#endif /* _SQUID_SRC_PARSER_CHARACTERSET_H */
class ClientDbRr: public RegisteredRunner
{
- public:
- virtual void run(const RunnerRegistry &);
+public:
+ virtual void run(const RunnerRegistry &);
};
RunnerRegistrationEntry(rrAfterConfig, ClientDbRr);
}
/** Adapt stream status to account for Range cases
- *
+ *
*/
clientStream_status_t
ClientSocketContext::socketState()
if (bytesSent == bytesExpected) // got everything
return STREAM_COMPLETE;
-
+
if (bytesSent > bytesExpected) // Error: Sent more than expected
return STREAM_UNPLANNED_COMPLETE;
}
ESIContext::setErrorMessage(char const *anError)
{
if (!errormessage)
- errormessage = xstrdup (anError);
+ errormessage = xstrdup(anError);
}
#endif /* USE_SQUID_ESI == 1 */
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
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
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;
{
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)
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;
}
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;
/* 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) {
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;
} else {
UserOs = ESI_OS_OTHER;
browser = ESI_BROWSER_OTHER;
- browserversion = xstrdup ("");
+ browserversion = xstrdup("");
}
}
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 *
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;
}
#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);
}
{
/* 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;
/* 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);
}
{
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;
}
/* 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)
{
}
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) {
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;
}
#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"
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);
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);
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 \
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 \
primaryEngine(NULL), loop_delay(0), error(false), runOnceResult(false)
STUB_NOP
-void EventLoop::registerEngine(AsyncEngine *engine) STUB
+ void EventLoop::registerEngine(AsyncEngine *engine) STUB
#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
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 */
CPPUNIT_ASSERT_EQUAL(3U,idx);
}
-
void
testSBuf::testAutoFind()
{
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);
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);
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);
}
run_stats = atoi(optarg);
break;
case 'f':
- fn = strdup(optarg);
+ fn = xstrdup(optarg);
fp = fopen(fn, "r");
break;
case 'i':
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;
}
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, " ");
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) {
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");
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);
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);
} 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) {
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) {
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);
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':
proxy_port = atoi(optarg);
break;
case 'h':
- proxy_addr = strdup(optarg);
+ proxy_addr = xstrdup(optarg);
break;
case 'n':
max_connections = atoi(optarg);
(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