Introduced aliases for it named String::rawBuf() and String::termedBuf().
Introduced String::defined() and String::undefined().
ACLExtUser::match(ACLChecklist *checklist)
{
if (checklist->request->extacl_user.size()) {
- return data->match(checklist->request->extacl_user.buf());
+ return data->match(checklist->request->extacl_user.unsafeBuf());
} else {
return -1;
}
if (hdr == NULL)
return false;
- debugs(28, 3, "aclHeaderData::match: checking '" << hdrName.buf() << "'");
+ debugs(28, 3, "aclHeaderData::match: checking '" << hdrName.unsafeBuf() << "'");
- String value = hdrId != HDR_BAD_HDR ? hdr->getStrOrList(hdrId) : hdr->getByName(hdrName.buf());
+ String value = hdrId != HDR_BAD_HDR ? hdr->getStrOrList(hdrId) : hdr->getByName(hdrName.unsafeBuf());
- return regex_rule->match(value.buf());
+ return regex_rule->match(value.unsafeBuf());
}
wordlist *
ACLHTTPHeaderData::dump()
{
wordlist *W = NULL;
- wordlistAdd(&W, hdrName.buf());
+ wordlistAdd(&W, hdrName.unsafeBuf());
wordlist * regex_dump = regex_rule->dump();
wordlistAddWl(&W, regex_dump);
wordlistDestroy(®ex_dump);
char* t = strtokFile();
assert (t != NULL);
hdrName = t;
- hdrId = httpHeaderIdByNameDef(hdrName.buf(), strlen(hdrName.buf()));
+ hdrId = httpHeaderIdByNameDef(hdrName.unsafeBuf(), strlen(hdrName.unsafeBuf()));
regex_rule->parse();
}
bool
ACLHTTPHeaderData::empty() const
{
- return (hdrId == HDR_BAD_HDR && !hdrName.buf()) || regex_rule->empty();
+ return (hdrId == HDR_BAD_HDR && !hdrName.unsafeBuf()) || regex_rule->empty();
}
ACLData<HttpHeader*> *
int
ACLUrlPathStrategy::match (ACLData<char const *> * &data, ACLChecklist *checklist)
{
- char *esc_buf = xstrdup(checklist->request->urlpath.buf());
+ char *esc_buf = xstrdup(checklist->request->urlpath.unsafeBuf());
rfc1738_unescape(esc_buf);
int result = data->match(esc_buf);
safe_free(esc_buf);
void *operator new(size_t);
void operator delete (void *);
static CommonPool *Factory (unsigned char _class, CompositePoolNode::Pointer&);
- char const* theClassTypeLabel() const {return typeLabel.buf();}
+ char const* theClassTypeLabel() const {return typeLabel.unsafeBuf();}
protected:
CommonPool();
DelayTaggedCmp(DelayTaggedBucket::Pointer const &left, DelayTaggedBucket::Pointer const &right)
{
/* for rate limiting, case insensitive */
- return left->tag.caseCmp(right->tag.buf());
+ return left->tag.caseCmp(right->tag.unsafeBuf());
}
void
void
DelayTaggedBucket::stats (StoreEntry *entry) const
{
- storeAppendPrintf(entry, " %s:", tag.buf());
+ storeAppendPrintf(entry, " %s:", tag.unsafeBuf());
theBucket.stats (entry);
}
{
/* Simulate async calls */
#ifdef _SQUID_WIN32_
- fd = aio_open(path.buf(), flags);
+ fd = aio_open(path.unsafeBuf(), flags);
#else
- fd = file_open(path.buf() , flags);
+ fd = file_open(path.unsafeBuf() , flags);
#endif
ioRequestor = callback;
fatal("Aiee! out of aiocb slots! - FIXME and wrap file_read\n");
debugs(79, 1, "WARNING: out of aiocb slots!");
/* fall back to blocking method */
- // file_read(fd, request->buf, request->len, request->offset, callback, data);
+ // file_read(fd, request->unsafeBuf, request->len, request->offset, callback, data);
return;
}
fatalf("Aiee! aio_read() returned error (%d) FIXME and wrap file_read !\n", errno);
debugs(79, 1, "WARNING: aio_read() returned error: " << xstrerror());
/* fall back to blocking method */
- // file_read(fd, request->buf, request->len, request->offset, callback, data);
+ // file_read(fd, request->unsafeBuf, request->len, request->offset, callback, data);
}
}
fatal("Aiee! out of aiocb slots FIXME and wrap file_write !\n");
debugs(79, 1, "WARNING: out of aiocb slots!");
/* fall back to blocking method */
- // file_write(fd, offset, buf, len, callback, data, freefunc);
+ // file_write(fd, offset, unsafeBuf, len, callback, data, freefunc);
return;
}
fatalf("Aiee! aio_write() returned error (%d) FIXME and wrap file_write !\n", errno);
debugs(79, 1, "WARNING: aio_write() returned error: " << xstrerror());
/* fall back to blocking method */
- // file_write(fd, offset, buf, len, callback, data, freefunc);
+ // file_write(fd, offset, unsafeBuf, len, callback, data, freefunc);
}
}
/* Ensure variable state is clean */
while (temp.getRaw()) {
- varState->feedData(temp->buf,temp->len);
+ varState->feedData(temp->unsafeBuf,temp->len);
temp = temp->next;
}
void
ESIVarState::removeVariable (String const &name)
{
- Variable *candidate = static_cast <Variable *>(variables.find (name.buf(), name.size()));
+ Variable *candidate = static_cast <Variable *>(variables.find (name.unsafeBuf(), name.size()));
if (candidate) {
/* XXX: remove me */
String S = state.header().getListMember (HDR_COOKIE, subref, ';');
if (S.size())
- ESISegment::ListAppend (state.getOutput(), S.buf(), S.size());
+ ESISegment::ListAppend (state.getOutput(), S.unsafeBuf(), S.size());
else if (found_default)
ESISegment::ListAppend (state.getOutput(), found_default, strlen (found_default));
}
if (state.header().has(HDR_ACCEPT_LANGUAGE)) {
if (!subref) {
String S (state.header().getList (HDR_ACCEPT_LANGUAGE));
- ESISegment::ListAppend (state.getOutput(), S.buf(), S.size());
+ ESISegment::ListAppend (state.getOutput(), S.unsafeBuf(), S.size());
} else {
if (state.header().hasListMember (HDR_ACCEPT_LANGUAGE, subref, ',')) {
s = "true";
String strVary (rep->header.getList (HDR_VARY));
- if (!strVary.size() || strVary.buf()[0] != '*') {
+ if (!strVary.size() || strVary.unsafeBuf()[0] != '*') {
rep->header.putStr (HDR_VARY, tempstr);
}
}
CcFieldsInfo, CC_ENUM_END);
if (type < 0) {
- debugs(65, 2, "hdr cc: unknown cache-directive: near '" << item << "' in '" << str->buf() << "'");
+ debugs(65, 2, "hdr cc: unknown cache-directive: near '" << item << "' in '" << str->unsafeBuf() << "'");
type = CC_OTHER;
}
if (EBIT_TEST(cc->mask, type)) {
if (type != CC_OTHER)
- debugs(65, 2, "hdr cc: ignoring duplicate cache-directive: near '" << item << "' in '" << str->buf() << "'");
+ debugs(65, 2, "hdr cc: ignoring duplicate cache-directive: near '" << item << "' in '" << str->unsafeBuf() << "'");
CcFieldsInfo[type].stat.repCount++;
{
assert(cc);
- if (cc->other.buf())
+ if (cc->other.unsafeBuf())
cc->other.clean();
memFree(cc, MEM_HTTP_HDR_CC);
if (EBIT_TEST(cc->mask, flag) && flag != CC_OTHER) {
/* print option name */
- packerPrintf(p, (pcount ? ", %s" : "%s"), CcFieldsInfo[flag].name.buf());
+ packerPrintf(p, (pcount ? ", %s" : "%s"), CcFieldsInfo[flag].name.unsafeBuf());
/* handle options with values */
}
if (cc->other.size())
- packerPrintf(p, (pcount ? ", %s" : "%s"), cc->other.buf());
+ packerPrintf(p, (pcount ? ", %s" : "%s"), cc->other.unsafeBuf());
}
/* negative max_age will clean old max_Age setting */
extern const HttpHeaderStat *dump_stat; /* argh! */
const int id = (int) val;
const int valid_id = id >= 0 && id < CC_ENUM_END;
- const char *name = valid_id ? CcFieldsInfo[id].name.buf() : "INVALID";
+ const char *name = valid_id ? CcFieldsInfo[id].name.unsafeBuf() : "INVALID";
if (count || valid_id)
storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n",
{
assert(f);
return httpHdrExtFieldDoCreate(
- f->name.buf(), f->name.size(),
- f->value.buf(), f->value.size());
+ f->name.unsafeBuf(), f->name.size(),
+ f->value.unsafeBuf(), f->value.size());
}
int count = 0;
assert(this && range_spec);
++ParsedCount;
- debugs(64, 8, "parsing range field: '" << range_spec->buf() << "'");
+ debugs(64, 8, "parsing range field: '" << range_spec->unsafeBuf() << "'");
/* check range type */
if (range_spec->caseCmp("bytes=", 6))
return 0;
/* skip "bytes="; hack! */
- pos = range_spec->buf() + 6;
+ pos = range_spec->unsafeBuf() + 6;
/* iterate through comma separated list */
while (strListGetItem(range_spec, ',', &item, &ilen, &pos)) {
ScFieldsInfo, SC_ENUM_END);
if (type < 0) {
- debugs(90, 2, "hdr sc: unknown control-directive: near '" << item << "' in '" << str->buf() << "'");
+ debugs(90, 2, "hdr sc: unknown control-directive: near '" << item << "' in '" << str->unsafeBuf() << "'");
type = SC_OTHER;
}
if (EBIT_TEST(sct->mask, type)) {
if (type != SC_OTHER)
- debugs(90, 2, "hdr sc: ignoring duplicate control-directive: near '" << item << "' in '" << str->buf() << "'");
+ debugs(90, 2, "hdr sc: ignoring duplicate control-directive: near '" << item << "' in '" << str->unsafeBuf() << "'");
ScFieldsInfo[type].stat.repCount++;
if (EBIT_TEST(sc->mask, flag) && flag != SC_OTHER) {
/* print option name */
- packerPrintf(p, (pcount ? ", %s" : "%s"), ScFieldsInfo[flag].name.buf());
+ packerPrintf(p, (pcount ? ", %s" : "%s"), ScFieldsInfo[flag].name.unsafeBuf());
/* handle options with values */
packerPrintf(p, "=%d", (int) sc->max_age);
if (flag == SC_CONTENT)
- packerPrintf(p, "=\"%s\"", sc->content.buf());
+ packerPrintf(p, "=\"%s\"", sc->content.unsafeBuf());
pcount++;
}
}
if (sc->target.size())
- packerPrintf (p, ";%s", sc->target.buf());
+ packerPrintf (p, ";%s", sc->target.unsafeBuf());
}
void
extern const HttpHeaderStat *dump_stat; /* argh! */
const int id = (int) val;
const int valid_id = id >= 0 && id < SC_ENUM_END;
- const char *name = valid_id ? ScFieldsInfo[id].name.buf() : "INVALID";
+ const char *name = valid_id ? ScFieldsInfo[id].name.unsafeBuf() : "INVALID";
if (count || valid_id)
storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n",
extern const HttpHeaderStat *dump_stat; /* argh! */
const int id = (int) val;
const int valid_id = id >= 0 && id < SC_ENUM_END;
- const char *name = valid_id ? ScFieldsInfo[id].name.buf() : "INVALID";
+ const char *name = valid_id ? ScFieldsInfo[id].name.unsafeBuf() : "INVALID";
if (count || valid_id)
storeAppendPrintf(sentry, "%2d\t %-20s\t %5d\t %6.2f\n",
while (node) {
HttpHdrScTarget *sct = (HttpHdrScTarget *)node->data;
- if (target && sct->target.buf() && !strcmp (target, sct->target.buf()))
+ if (target && sct->target.unsafeBuf() && !strcmp (target, sct->target.unsafeBuf()))
return sct;
- else if (!target && !sct->target.buf())
+ else if (!target && !sct->target.unsafeBuf())
return sct;
node = node->next;
{
HttpHdrScTarget *dup;
assert(sc);
- dup = httpHdrScTargetCreate(sc->target.buf());
+ dup = httpHdrScTargetCreate(sc->target.unsafeBuf());
dup->mask = sc->mask;
dup->max_age = sc->max_age;
dup->content = sc->content;
if (e->id != HDR_OTHER)
delById(e->id);
else
- delByName(e->name.buf());
+ delByName(e->name.unsafeBuf());
}
pos = HttpHeaderInitPos;
}
if (e->id == HDR_CONTENT_LENGTH && (e2 = findEntry(e->id)) != NULL) {
- if (e->value.cmp(e2->value.buf()) != 0) {
+ if (e->value.cmp(e2->value.unsafeBuf()) != 0) {
int64_t l1, l2;
debugs(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2,
"WARNING: found two conflicting content-length headers in {" << getStringPrefix(header_start, header_end) << "}");
goto reset;
}
- if (!httpHeaderParseOffset(e->value.buf(), &l1)) {
- debugs(55, 1, "WARNING: Unparseable content-length '" << e->value.buf() << "'");
+ if (!httpHeaderParseOffset(e->value.unsafeBuf(), &l1)) {
+ debugs(55, 1, "WARNING: Unparseable content-length '" << e->value.unsafeBuf() << "'");
delete e;
continue;
- } else if (!httpHeaderParseOffset(e2->value.buf(), &l2)) {
- debugs(55, 1, "WARNING: Unparseable content-length '" << e2->value.buf() << "'");
+ } else if (!httpHeaderParseOffset(e2->value.unsafeBuf(), &l2)) {
+ debugs(55, 1, "WARNING: Unparseable content-length '" << e2->value.unsafeBuf() << "'");
delById(e2->id);
} else if (l1 > l2) {
delById(e2->id);
}
}
- if (e->id == HDR_OTHER && stringHasWhitespace(e->name.buf())) {
+ if (e->id == HDR_OTHER && stringHasWhitespace(e->name.unsafeBuf())) {
debugs(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2,
"WARNING: found whitespace in HTTP header name {" <<
getStringPrefix(field_start, field_end) << "}");
while ((e = getEntry(&pos))) {
if (e->id == id)
- strListAdd(s, e->value.buf(), ',');
+ strListAdd(s, e->value.unsafeBuf(), ',');
}
/*
while ((e = getEntry(&pos))) {
if (e->id == id)
- strListAdd(&s, e->value.buf(), ',');
+ strListAdd(&s, e->value.unsafeBuf(), ',');
}
/*
/* Sorry, an unknown header name. Do linear search */
while ((e = getEntry(&pos))) {
if (e->id == HDR_OTHER && e->name.caseCmp(name) == 0) {
- strListAdd(&result, e->value.buf(), ',');
+ strListAdd(&result, e->value.unsafeBuf(), ',');
}
}
assert(Headers[id].type == ftDate_1123); /* must be of an appropriate type */
if ((e = findEntry(id))) {
- value = parse_rfc1123(e->value.buf());
+ value = parse_rfc1123(e->value.unsafeBuf());
httpHeaderNoteParsedEntry(e->id, e->value, value < 0);
}
if ((e = findEntry(id))) {
httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
- return e->value.buf();
+ return e->value.unsafeBuf();
}
return NULL;
if ((e = findLastEntry(id))) {
httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
- return e->value.buf();
+ return e->value.unsafeBuf();
}
return NULL;
HttpHeaderEntry *e;
if ((e = findEntry(HDR_CONTENT_RANGE))) {
- cr = httpHdrContRangeParseCreate(e->value.buf());
+ cr = httpHdrContRangeParseCreate(e->value.unsafeBuf());
httpHeaderNoteParsedEntry(e->id, e->value, !cr);
}
assert(Headers[id].type == ftETag); /* must be of an appropriate type */
if ((e = findEntry(id)))
- etagParseInit(&etag, e->value.buf());
+ etagParseInit(&etag, e->value.unsafeBuf());
return etag;
}
memset(&tot, 0, sizeof(tot));
if ((e = findEntry(id))) {
- const char *str = e->value.buf();
+ const char *str = e->value.unsafeBuf();
/* try as an ETag */
if (etagParseInit(&tot.tag, str)) {
Headers[id].stat.aliveCount++;
- debugs(55, 9, "created HttpHeaderEntry " << this << ": '" << name.buf() << " : " << value.buf());
+ debugs(55, 9, "created HttpHeaderEntry " << this << ": '" << name.unsafeBuf() << " : " << value.unsafeBuf());
}
HttpHeaderEntry::~HttpHeaderEntry()
{
assert_eid(id);
- debugs(55, 9, "destroying entry " << this << ": '" << name.buf() << ": " << value.buf() << "'");
+ debugs(55, 9, "destroying entry " << this << ": '" << name.unsafeBuf() << ": " << value.unsafeBuf() << "'");
/* clean name if needed */
if (id == HDR_OTHER)
if (field_end - value_start > 65534) {
/* String must be LESS THAN 64K and it adds a terminating NULL */
- debugs(55, 1, "WARNING: ignoring '" << name.buf() << "' header of " << (field_end - value_start) << " bytes");
+ debugs(55, 1, "WARNING: ignoring '" << name.unsafeBuf() << "' header of " << (field_end - value_start) << " bytes");
if (id == HDR_OTHER)
name.clean();
Headers[id].stat.aliveCount++;
- debugs(55, 9, "parsed HttpHeaderEntry: '" << name.buf() << ": " << value.buf() << "'");
+ debugs(55, 9, "parsed HttpHeaderEntry: '" << name.unsafeBuf() << ": " << value.unsafeBuf() << "'");
- return new HttpHeaderEntry(id, name.buf(), value.buf());
+ return new HttpHeaderEntry(id, name.unsafeBuf(), value.unsafeBuf());
}
HttpHeaderEntry *
HttpHeaderEntry::clone() const
{
- return new HttpHeaderEntry(id, name.buf(), value.buf());
+ return new HttpHeaderEntry(id, name.unsafeBuf(), value.unsafeBuf());
}
void
HttpHeaderEntry::packInto(Packer * p) const
{
assert(p);
- packerAppend(p, name.buf(), name.size());
+ packerAppend(p, name.unsafeBuf(), name.size());
packerAppend(p, ": ", 2);
- packerAppend(p, value.buf(), value.size());
+ packerAppend(p, value.unsafeBuf(), value.size());
packerAppend(p, "\r\n", 2);
}
assert_eid (id);
assert (Headers[id].type == ftInt);
int val = -1;
- int ok = httpHeaderParseInt(value.buf(), &val);
+ int ok = httpHeaderParseInt(value.unsafeBuf(), &val);
httpHeaderNoteParsedEntry(id, value, !ok);
/* XXX: Should we check ok - ie
* return ok ? -1 : value;
assert_eid (id);
assert (Headers[id].type == ftInt64);
int64_t val = -1;
- int ok = httpHeaderParseOffset(value.buf(), &val);
+ int ok = httpHeaderParseOffset(value.unsafeBuf(), &val);
httpHeaderNoteParsedEntry(id, value, !ok);
/* XXX: Should we check ok - ie
* return ok ? -1 : value;
if (error) {
Headers[id].stat.errCount++;
- debugs(55, 2, "cannot parse hdr field: '" << Headers[id].name.buf() << ": " << context.buf() << "'");
+ debugs(55, 2, "cannot parse hdr field: '" << Headers[id].name.unsafeBuf() << ": " << context.unsafeBuf() << "'");
}
}
{
const int id = (int) val;
const int valid_id = id >= 0 && id < HDR_ENUM_END;
- const char *name = valid_id ? Headers[id].name.buf() : "INVALID";
+ const char *name = valid_id ? Headers[id].name.unsafeBuf() : "INVALID";
int visible = count > 0;
/* for entries with zero count, list only those that belong to current type of message */
for (ht = (http_hdr_type)0; ht < HDR_ENUM_END; ++ht) {
HttpHeaderFieldInfo *f = Headers + ht;
storeAppendPrintf(e, "%2d\t %-25s\t %5d\t %6.3f\t %6.3f\n",
- f->id, f->name.buf(), f->stat.aliveCount,
+ f->id, f->name.unsafeBuf(), f->stat.aliveCount,
xpercent(f->stat.errCount, f->stat.parsCount),
xpercent(f->stat.repCount, f->stat.seenCount));
}
if (name_len >= 0 && name_len != info[i].name.size())
continue;
- if (!strncasecmp(name, info[i].name.buf(),
+ if (!strncasecmp(name, info[i].name.unsafeBuf(),
name_len < 0 ? info[i].name.size() + 1 : name_len))
return info[i].id;
}
assert(id >= 0 && id < HDR_ENUM_END);
- return Headers[id].name.buf();
+ return Headers[id].name.unsafeBuf();
}
int
int headers_deleted = 0;
while ((e = getEntry(&pos))) {
- if (strListIsMember(&strConnection, e->name.buf(), ','))
+ if (strListIsMember(&strConnection, e->name.unsafeBuf(), ','))
delAt(pos, headers_deleted);
}
if (headers_deleted)
delim[2][1] = del;
if (!*pos) {
- *pos = str->buf();
+ *pos = str->unsafeBuf();
if (!*pos)
return 0;
two = otherRep->header.getStrOrList(HDR_ETAG);
- if (!one.buf() || !two.buf() || strcasecmp (one.buf(), two.buf())) {
+ if (!one.unsafeBuf() || !two.unsafeBuf() || strcasecmp (one.unsafeBuf(), two.unsafeBuf())) {
one.clean();
two.clean();
return 0;
two = otherRep->header.getStrOrList(HDR_CONTENT_MD5);
- if (!one.buf() || !two.buf() || strcasecmp (one.buf(), two.buf())) {
+ if (!one.unsafeBuf() || !two.unsafeBuf() || strcasecmp (one.unsafeBuf(), two.unsafeBuf())) {
one.clean();
two.clean();
return 0;
bool HttpReply::sanityCheckStartLine(MemBuf *buf, http_status *error)
{
if (buf->contentSize() >= protoPrefix.size() && protoPrefix.cmp(buf->content(), protoPrefix.size()) != 0) {
- debugs(58, 3, "HttpReply::sanityCheckStartLine: missing protocol prefix (" << protoPrefix.buf() << ") in '" << buf->content() << "'");
+ debugs(58, 3, "HttpReply::sanityCheckStartLine: missing protocol prefix (" << protoPrefix.unsafeBuf() << ") in '" << buf->content() << "'");
*error = HTTP_INVALID_HEADER;
return false;
}
HttpRequest *
HttpRequest::clone() const
{
- HttpRequest *copy = new HttpRequest(method, protocol, urlpath.buf());
+ HttpRequest *copy = new HttpRequest(method, protocol, urlpath.unsafeBuf());
// TODO: move common cloning clone to Msg::copyTo() or copy ctor
copy->header.append(&header);
copy->hdrCacheInit();
assert(p);
/* pack request-line */
packerPrintf(p, "%s %s HTTP/1.0\r\n",
- RequestMethodStr(method), urlpath.buf());
+ RequestMethodStr(method), urlpath.unsafeBuf());
/* headers */
header.packInto(p);
/* trailer */
assert(e);
/* check connection header */
- if (strConn && strListIsMember(strConn, e->name.buf(), ','))
+ if (strConn && strListIsMember(strConn, e->name.unsafeBuf(), ','))
return 0;
return 1;
return urlCanonical((HttpRequest*)this);
if (urlpath.size())
- return urlpath.buf();
+ return urlpath.unsafeBuf();
return "/";
}
return RequestMethodStr[theMethod];
} else {
if (theImage.size()>0) {
- return theImage.buf();
+ return theImage.unsafeBuf();
} else {
return "METHOD_OTHER";
}
// as ICAP headers.
if (virgin.header->header.has(HDR_PROXY_AUTHENTICATE))
buf.Printf("Proxy-Authenticate: %s\r\n",
- virgin.header->header.getByName("Proxy-Authenticate").buf());
+ virgin.header->header.getByName("Proxy-Authenticate").unsafeBuf());
if (virgin.header->header.has(HDR_PROXY_AUTHORIZATION))
buf.Printf("Proxy-Authorization: %s\r\n",
- virgin.header->header.getByName("Proxy-Authorization").buf());
+ virgin.header->header.getByName("Proxy-Authorization").unsafeBuf());
buf.Printf("Encapsulated: ");
if (TheICAPConfig.send_client_username && request)
makeUsernameHeader(request, buf);
- // fprintf(stderr, "%s\n", buf.content());
+ // fprintf(stderr, "%s\n", unsafeBuf.content());
buf.append(ICAP::crlf, 2); // terminate ICAP header
Must(!preview.ad());
// do not add last-chunk because our Encapsulated header says null-body
- // addLastRequestChunk(buf);
+ // addLastRequestChunk(unsafeBuf);
preview.wrote(0, true);
Must(preview.done());
Must(virgin.body_pipe->setConsumerIfNotLate(this));
// make sure TheBackupLimit is in-sync with the buffer size
- Must(TheBackupLimit <= static_cast<size_t>(msg->body_pipe->buf().max_capacity));
+ Must(TheBackupLimit <= static_cast<size_t>(msg->body_pipe->unsafeBuf().max_capacity));
} else {
debugs(93, 6, "ICAPModXact does not expect virgin body");
Must(msg->body_pipe == NULL);
{
const String s = h->getByName(fname);
- if (s.size() && xisdigit(*s.buf()))
- value = atoi(s.buf());
+ if (s.size() && xisdigit(*s.unsafeBuf()))
+ value = atoi(s.unsafeBuf());
else
value = -1;
if (eLen < urlLen) {
const int eOff = urlLen - eLen;
// RFC 3507 examples imply that extensions come without leading '.'
- if (urlPath.buf()[eOff-1] == '.' &&
- strcmp(urlPath.buf() + eOff, e->key) == 0) {
+ if (urlPath.unsafeBuf()[eOff-1] == '.' &&
+ strcmp(urlPath.unsafeBuf() + eOff, e->key) == 0) {
debugs(93,7, "ICAPOptions url " << urlPath << " matches " <<
name << " extension " << e->key);
return true;
if (!method_found) {
debugs(93,1, "WARNING: Squid is configured to use ICAP method " <<
cfg().methodStr() <<
- " for service " << cfg().uri.buf() <<
- " but OPTIONS response declares the methods are " << method_list.buf());
+ " for service " << cfg().uri.unsafeBuf() <<
+ " but OPTIONS response declares the methods are " << method_list.unsafeBuf());
}
}
// TODO: If skew is negative, the option will be considered down
// because of stale options. We should probably change this.
debugs(93, 1, "ICAP service's clock is skewed by " << skew <<
- " seconds: " << cfg().uri.buf());
+ " seconds: " << cfg().uri.unsafeBuf());
}
}
disableRetries(); // this will also safely drain pconn pool
// TODO: check whether NULL domain is appropriate here
- connection = icapPconnPool->pop(s.cfg().host.buf(), s.cfg().port, NULL, client_addr, isRetriable);
+ connection = icapPconnPool->pop(s.cfg().host.unsafeBuf(), s.cfg().port, NULL, client_addr, isRetriable);
if (connection >= 0) {
debugs(93,3, HERE << "reused pconn FD " << connection);
IpAddress outgoing;
connection = comm_open(SOCK_STREAM, 0, outgoing,
- COMM_NONBLOCKING, s.cfg().uri.buf());
+ COMM_NONBLOCKING, s.cfg().uri.unsafeBuf());
if (connection < 0)
dieOnConnectionFailure(); // throws
- debugs(93,3, typeName << " opens connection to " << s.cfg().host.buf() << ":" << s.cfg().port);
+ debugs(93,3, typeName << " opens connection to " << s.cfg().host.unsafeBuf() << ":" << s.cfg().port);
// TODO: service bypass status may differ from that of a transaction
typedef CommCbMemFunT<ICAPXaction, CommTimeoutCbParams> TimeoutDialer;
typedef CommCbMemFunT<ICAPXaction, CommConnectCbParams> ConnectDialer;
connector = asyncCall(93,3, "ICAPXaction::noteCommConnected",
ConnectDialer(this, &ICAPXaction::noteCommConnected));
- commConnectStart(connection, s.cfg().host.buf(), s.cfg().port, connector);
+ commConnectStart(connection, s.cfg().host.unsafeBuf(), s.cfg().port, connector);
}
/*
debugs(93,3, HERE << "pushing pconn" << status());
AsyncCall::Pointer call = NULL;
commSetTimeout(connection, -1, call);
- icapPconnPool->push(connection, theService->cfg().host.buf(),
+ icapPconnPool->push(connection, theService->cfg().host.unsafeBuf(),
theService->cfg().port, NULL, client_addr);
disableRetries();
} else {
{
debugs(93, 2, HERE << typeName << " failed: timeout with " <<
theService->cfg().methodStr() << " " <<
- theService->cfg().uri.buf() << status());
+ theService->cfg().uri.unsafeBuf() << status());
reuseConnection = false;
service().noteFailure();
/*
* See comments in ICAPXaction.h about why we use commBuf
- * here instead of reading directly into readBuf.buf.
+ * here instead of reading directly into readBuf.unsafeBuf.
*/
typedef CommCbMemFunT<ICAPXaction, CommIoCbParams> Dialer;
reader = asyncCall(93,3, "ICAPXaction::noteCommRead",
/*
* See comments in ICAPXaction.h about why we use commBuf
- * here instead of reading directly into readBuf.buf.
+ * here instead of reading directly into readBuf.unsafeBuf.
*/
if (io.size > 0) {
void *LoadableModule::openModule(int mode)
{
# if XSTD_USE_LIBLTDL
- return lt_dlopen(theName.buf());
+ return lt_dlopen(theName.unsafeBuf());
# else
return dlopen(theName.c_str(),
mode == lmNow ? RTLD_NOW : RTLD_LAZY);
_SQUID_INLINE_ char &operator [](unsigned int pos);
_SQUID_INLINE_ int size() const;
- _SQUID_INLINE_ char const * buf() const;
+ _SQUID_INLINE_ char const * unsafeBuf() const;
+
+ /**
+ * \retval true the String has some contents
+ */
+ _SQUID_INLINE_ bool defined() const;
+ /**
+ * \retval true the String does not hold any contents
+ */
+ _SQUID_INLINE_ bool undefined() const;
+ /**
+ * Returns a raw pointer to the underlying backing store. The caller has been
+ * verified not to make any assumptions about null-termination
+ */
+ _SQUID_INLINE_ char const * rawBuf() const;
+ /**
+ * Returns a raw pointer to the underlying backing store.
+ * The caller requires it to be null-terminated.
+ */
+ _SQUID_INLINE_ char const * termedBuf() const;
void limitInit(const char *str, int len); // TODO: rename to assign()
void clean();
void reset(char const *str);
{
clean(); // TODO: optimize to avoid cleaning the buffer we can use
if (old.size() > 0)
- allocAndFill(old.buf(), old.size());
+ allocAndFill(old.unsafeBuf(), old.size());
return *this;
}
String::String (String const &old) : size_(0), len_(0), buf_(NULL)
{
if (old.size() > 0)
- allocAndFill(old.buf(), old.size());
+ allocAndFill(old.unsafeBuf(), old.size());
#if DEBUGSTRINGS
StringRegistry::Instance().add(this);
PROF_start(StringClean);
assert(this);
- if (buf())
+ if (unsafeBuf())
memFreeString(size_, buf_);
len_ = 0;
snew.allocBuffer(snew.len_ + 1);
if (len_)
- xmemcpy(snew.buf_, buf(), len_);
+ xmemcpy(snew.buf_, unsafeBuf(), len_);
if (len)
xmemcpy(snew.buf_ + len_, str, len);
void
String::append(String const &old)
{
- append (old.buf(), old.len_);
+ append (old.unsafeBuf(), old.len_);
}
void
void
String::stat(StoreEntry *entry) const
{
- storeAppendPrintf(entry, "%p : %d/%d \"%s\"\n",this,len_, size_, buf());
+ storeAppendPrintf(entry, "%p : %d/%d \"%s\"\n",this,len_, size_, unsafeBuf());
}
StringRegistry &
}
char const *
-String::buf() const
+String::unsafeBuf() const
+{
+ return buf_;
+}
+
+bool String::defined() const
+{
+ return buf_!=NULL;
+}
+
+bool String::undefined() const
+{
+ return buf_==NULL;
+}
+
+char const *
+String::rawBuf() const
+{
+ return buf_;
+}
+
+char const *
+String::termedBuf() const
{
return buf_;
}
const char *
String::pos(char const *aString) const
{
- return strstr(buf(), aString);
+ return strstr(unsafeBuf(), aString);
}
const char *
String::pos(char const ch) const
{
- return strchr(buf(), ch);
+ return strchr(unsafeBuf(), ch);
}
const char *
String::rpos(char const ch) const
{
- return strrchr(buf(), (ch));
+ return strrchr(unsafeBuf(), (ch));
}
int
if (aString == NULL || aString[0] == '\0')
return 1;
- return strcmp(buf(), aString);
+ return strcmp(unsafeBuf(), aString);
}
int
if (aString == NULL || aString[0] == '\0')
return 1;
- return strncmp(buf(), aString, count);
+ return strncmp(unsafeBuf(), aString, count);
}
int
if (aString.size() == 0)
return 1;
- return strcmp(buf(), aString.buf());
+ return strcmp(unsafeBuf(), aString.unsafeBuf());
}
int
String::caseCmp(char const *aString) const
{
- return strcasecmp(buf(), aString);
+ return strcasecmp(unsafeBuf(), aString);
}
int
String::caseCmp(char const *aString, size_t count) const
{
- return strncasecmp(buf(), aString, count);
+ return strncasecmp(unsafeBuf(), aString, count);
}
void
std::ostream &
operator<<(std::ostream& os, String const &aString)
{
- os << aString.buf();
+ os << aString.unsafeBuf();
return os;
}
if (al->request)
sb = al->request->header.getByName(fmt->data.header.header);
- out = sb.buf();
+ out = sb.unsafeBuf();
quote = 1;
if (al->reply)
sb = al->reply->header.getByName(fmt->data.header.header);
- out = sb.buf();
+ out = sb.unsafeBuf();
quote = 1;
if (al->request)
sb = al->request->header.getByNameListMember(fmt->data.header.header, fmt->data.header.element, fmt->data.header.separator);
- out = sb.buf();
+ out = sb.unsafeBuf();
quote = 1;
if (al->reply)
sb = al->reply->header.getByNameListMember(fmt->data.header.header, fmt->data.header.element, fmt->data.header.separator);
- out = sb.buf();
+ out = sb.unsafeBuf();
quote = 1;
case LFT_REQUEST_URLPATH:
if (al->request) {
- out = al->request->urlpath.buf();
+ out = al->request->urlpath.unsafeBuf();
quote = 1;
}
break;
case LFT_TAG:
if (al->request)
- out = al->request->tag.buf();
+ out = al->request->tag.unsafeBuf();
quote = 1;
case LFT_EXT_LOG:
if (al->request)
- out = al->request->extacl_log.buf();
+ out = al->request->extacl_log.unsafeBuf();
quote = 1;
typedef Services::iterator SCI;
for (SCI i = AllServices().begin(); i != AllServices().end(); ++i) {
const ServiceConfig &cfg = (*i)->cfg();
- storeAppendPrintf(entry, "%s %s_%s %s %d %s\n", name, cfg.key.buf(),
- cfg.methodStr(), cfg.vectPointStr(), cfg.bypass, cfg.uri.buf());
+ storeAppendPrintf(entry, "%s %s_%s %s %d %s\n", name, cfg.key.unsafeBuf(),
+ cfg.methodStr(), cfg.vectPointStr(), cfg.bypass, cfg.uri.unsafeBuf());
}
}
{
typedef Groups::iterator GI;
for (GI i = AllGroups().begin(); i != AllGroups().end(); ++i)
- storeAppendPrintf(entry, "%s %s\n", name, (*i)->id.buf());
+ storeAppendPrintf(entry, "%s %s\n", name, (*i)->id.unsafeBuf());
}
void
typedef AccessRules::iterator CI;
for (CI i = AllRules().begin(); i != AllRules().end(); ++i) {
- snprintf(nom, 64, "%s %s", name, (*i)->groupId.buf());
+ snprintf(nom, 64, "%s %s", name, (*i)->groupId.unsafeBuf());
dump_acl_access(entry, nom, (*i)->acl);
}
}
ConfigParser::ParseString(&uri);
debugs(3, 5, HERE << cfg_filename << ':' << config_lineno << ": " <<
- key.buf() << " " << method_point << " " << bypass);
+ key.unsafeBuf() << " " << method_point << " " << bypass);
method = parseMethod(method_point);
point = parseVectPoint(method_point);
// extract scheme and use it as the service_configConfig protocol
const char *schemeSuffix = "://";
if (const char *schemeEnd = uri.pos(schemeSuffix))
- protocol.limitInit(uri.buf(), schemeEnd - uri.buf());
+ protocol.limitInit(uri.unsafeBuf(), schemeEnd - uri.unsafeBuf());
debugs(3, 5, HERE << cfg_filename << ':' << config_lineno << ": " <<
"service protocol is " << protocol);
if (!protocol.size())
return false;
// skip scheme
- const char *s = uri.buf() + protocol.size() + strlen(schemeSuffix);
+ const char *s = uri.unsafeBuf() + protocol.size() + strlen(schemeSuffix);
const char *e;
aLogEntry->http.version = request->http_ver;
aLogEntry->hier = request->hier;
aLogEntry->cache.requestSize += request->content_length;
- aLogEntry->cache.extuser = request->extacl_user.buf();
+ aLogEntry->cache.extuser = request->extacl_user.unsafeBuf();
if (request->auth_user_request) {
if (al.reply) {
al.http.code = al.reply->sline.status;
- al.http.content_type = al.reply->content_type.buf();
+ al.http.content_type = al.reply->content_type.unsafeBuf();
} else if (loggingEntry() && loggingEntry()->mem_obj) {
al.http.code = loggingEntry()->mem_obj->getReply()->sline.status;
- al.http.content_type = loggingEntry()->mem_obj->getReply()->content_type.buf();
+ al.http.content_type = loggingEntry()->mem_obj->getReply()->content_type.unsafeBuf();
}
debugs(33, 9, "clientLogRequest: http.code='" << al.http.code << "'");
static void
clientPackTermBound(String boundary, MemBuf * mb)
{
- mb->Printf("\r\n--%s--\r\n", boundary.buf());
+ mb->Printf("\r\n--%s--\r\n", boundary.unsafeBuf());
debugs(33, 6, "clientPackTermBound: buf offset: " << mb->size);
}
/* put boundary */
debugs(33, 5, "clientPackRangeHdr: appending boundary: " <<
- boundary.buf());
+ boundary.unsafeBuf());
/* rfc2046 requires to _prepend_ boundary with <crlf>! */
- mb->Printf("\r\n--%s\r\n", boundary.buf());
+ mb->Printf("\r\n--%s\r\n", boundary.unsafeBuf());
/* stuff the header with required entries and pack it */
}
/**
- * extracts a "range" from *buf and appends them to mb, updating
+ * extracts a "range" from *unsafeBuf and appends them to mb, updating
* all offsets and such.
*/
void
hdr->delById(HDR_CONTENT_TYPE);
httpHeaderPutStrf(hdr, HDR_CONTENT_TYPE,
"multipart/byteranges; boundary=\"%s\"",
- http->range_iter.boundary.buf());
+ http->range_iter.boundary.unsafeBuf());
/* Content-Length is not required in multipart responses
* but it is always nice to have one */
actual_clen = http->mRangeCLen();
req_sz = HttpParserReqSz(hp);
}
- /* We know the whole request is in hp->buf now */
+ /* We know the whole request is in hp->unsafeBuf now */
assert(req_sz <= (size_t) hp->bufsiz);
request->flags.spoof_client_ip = conn->port->spoof_client_ip;
}
- if (internalCheck(request->urlpath.buf())) {
+ if (internalCheck(request->urlpath.unsafeBuf())) {
if (internalHostnameIs(request->GetHost()) &&
request->port == getMyPort()) {
http->flags.internal = 1;
- } else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.buf())) {
+ } else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.unsafeBuf())) {
request->SetHost(internalHostname());
request->port = getMyPort();
http->flags.internal = 1;
}
/**
- * called when new request body data has been buffered in in.buf
+ * called when new request body data has been buffered in in.unsafeBuf
* may close the connection if we were closing and piped everything out
*/
void
int connection_auth_blocked = 0;
while ((e = hdr->getEntry(&pos))) {
if (e->id == HDR_WWW_AUTHENTICATE) {
- const char *value = e->value.buf();
+ const char *value = e->value.unsafeBuf();
if ((strncasecmp(value, "NTLM", 4) == 0 &&
(value[4] == '\0' || value[4] == ' '))
ThisCache);
strListAdd(&strVia, bbuf, ',');
hdr->delById(HDR_VIA);
- hdr->putStr(HDR_VIA, strVia.buf());
+ hdr->putStr(HDR_VIA, strVia.unsafeBuf());
}
/* Signal keep-alive if needed */
hdr->putStr(http->flags.accel ? HDR_CONNECTION : HDR_PROXY_CONNECTION,
}
/*
- * accepts chunk of a http message in buf, parses prefix, filters headers and
+ * accepts chunk of a http message in unsafeBuf, parses prefix, filters headers and
* such, writes processed message to the message recipient
*/
void
const char *asciiaddr;
int l;
struct in_addr addr;
- p = request->x_forwarded_for_iterator.buf();
+ p = request->x_forwarded_for_iterator.unsafeBuf();
l = request->x_forwarded_for_iterator.size();
/*
int may_pin = 0;
while ((e = req_hdr->getEntry(&pos))) {
if (e->id == HDR_AUTHORIZATION || e->id == HDR_PROXY_AUTHORIZATION) {
- const char *value = e->value.buf();
+ const char *value = e->value.unsafeBuf();
if (strncasecmp(value, "NTLM ", 5) == 0
||
strncasecmp(value, "Negotiate ", 10) == 0
}
#if FORW_VIA_DB
- fvdbCountVia(s.buf());
+ fvdbCountVia(s.unsafeBuf());
#endif
if (req_hdr->has(HDR_X_FORWARDED_FOR)) {
String s = req_hdr->getList(HDR_X_FORWARDED_FOR);
- fvdbCountForw(s.buf());
+ fvdbCountForw(s.unsafeBuf());
s.clean();
}
assert(request_satisfaction_mode);
assert(adaptedBodySource != NULL);
- if (const size_t contentSize = adaptedBodySource->buf().contentSize()) {
+ if (const size_t contentSize = adaptedBodySource->unsafeBuf().contentSize()) {
BodyPipeCheckout bpc(*adaptedBodySource);
- const StoreIOBuffer ioBuf(&bpc.buf, request_satisfaction_offset);
+ const StoreIOBuffer ioBuf(&bpc.unsafeBuf, request_satisfaction_offset);
storeEntry()->write(ioBuf);
// assume can write everything
request_satisfaction_offset += contentSize;
- bpc.buf.consume(contentSize);
+ bpc.unsafeBuf.consume(contentSize);
bpc.checkIn();
}
const String value = squidId == HDR_OTHER ?
theHeader.getByName(name.image().c_str()) :
theHeader.getStrOrList(squidId);
- return Value::FromTempString(value.buf());
+ return Value::FromTempString(value.unsafeBuf());
}
void
Ecap::RequestLineRep::Area
Ecap::RequestLineRep::uri() const
{
- return Area::FromTempBuffer(theMessage.urlpath.buf(),
+ return Area::FromTempBuffer(theMessage.urlpath.unsafeBuf(),
theMessage.urlpath.size());
}
bool Ecap::ServiceRep::wantsUrl(const String &urlPath) const
{
Must(up());
- return theService->wantsUrl(urlPath.buf());
+ return theService->wantsUrl(urlPath.unsafeBuf());
}
Adaptation::Initiate *
Packer p;
str.Printf("%s %s HTTP/%d.%d\n",
RequestMethodStr(request->method),
- request->urlpath.size() ? request->urlpath.buf() : "/",
+ request->urlpath.size() ? request->urlpath.unsafeBuf() : "/",
request->http_ver.major, request->http_ver.minor);
packerToMemInit(&p, &str);
request->header.packInto(&p);
Packer p;
mb.Printf("%s %s HTTP/%d.%d\n",
RequestMethodStr(request->method),
- request->urlpath.size() ? request->urlpath.buf() : "/",
+ request->urlpath.size() ? request->urlpath.unsafeBuf() : "/",
request->http_ver.major, request->http_ver.minor);
packerToMemInit(&p, &mb);
request->header.packInto(&p);
*/
if (!Config.errorDirectory && request && request->header.getList(HDR_ACCEPT_LANGUAGE, &hdr) ) {
- const char *buf = hdr.buf(); // raw header string for parsing
+ const char *unsafeBuf = hdr.unsafeBuf(); // raw header string for parsing
int pos = 0; // current parsing position in header string
char *reset = NULL; // where to reset the p pointer for each new tag file
char *dt = NULL;
* - IFF a tag contains only two characters we can wildcard ANY translations matching: <it> '-'? .*
* with preference given to an exact match.
*/
- while (pos < hdr.size() && buf[pos] != ';' && buf[pos] != ',' && !xisspace(buf[pos]) && dt < (dir+256) ) {
- *dt++ = xtolower(buf[pos++]);
+ while (pos < hdr.size() && unsafeBuf[pos] != ';' && unsafeBuf[pos] != ',' && !xisspace(unsafeBuf[pos]) && dt < (dir+256) ) {
+ *dt++ = xtolower(unsafeBuf[pos++]);
}
*dt++ = '\0'; // nul-terminated the filename content string before system use.
- debugs(4, 9, HERE << "STATE: dt='" << dt << "', reset='" << reset << "', reset[1]='" << reset[1] << "', pos=" << pos << ", buf='" << &buf[pos] << "'");
+ debugs(4, 9, HERE << "STATE: dt='" << dt << "', reset='" << reset << "', reset[1]='" << reset[1] << "', pos=" << pos << ", buf='" << &unsafeBuf[pos] << "'");
/* if we found anything we might use, try it. */
if (*reset != '\0') {
dt = reset; // reset for next tag testing. we replace the failed name instead of cloning.
// IFF we terminated the tag on ';' we need to skip the 'q=' bit to the next ',' or end.
- while (pos < hdr.size() && buf[pos] != ',') pos++;
- if (buf[pos] == ',') pos++;
+ while (pos < hdr.size() && unsafeBuf[pos] != ',') pos++;
+ if (unsafeBuf[pos] == ',') pos++;
}
}
#endif /* USE_ERR_LOCALES */
external_acl_cache_touch(acl->def, entry);
result = entry->result;
- external_acl_message = entry->message.buf();
+ external_acl_message = entry->message.unsafeBuf();
debugs(82, 2, "aclMatchExternal: " << acl->def->name << " = " << result);
break;
case _external_acl_format::EXT_ACL_PATH:
- str = request->urlpath.buf();
+ str = request->urlpath.unsafeBuf();
break;
case _external_acl_format::EXT_ACL_METHOD:
case _external_acl_format::EXT_ACL_HEADER_REQUEST:
sb = request->header.getByName(format->header);
- str = sb.buf();
+ str = sb.unsafeBuf();
break;
case _external_acl_format::EXT_ACL_HEADER_REQUEST_ID:
sb = request->header.getStrOrList(format->header_id);
- str = sb.buf();
+ str = sb.unsafeBuf();
break;
case _external_acl_format::EXT_ACL_HEADER_REQUEST_MEMBER:
sb = request->header.getByNameListMember(format->header, format->member, format->separator);
- str = sb.buf();
+ str = sb.unsafeBuf();
break;
case _external_acl_format::EXT_ACL_HEADER_REQUEST_ID_MEMBER:
sb = request->header.getListMember(format->header_id, format->member, format->separator);
- str = sb.buf();
+ str = sb.unsafeBuf();
break;
case _external_acl_format::EXT_ACL_HEADER_REPLY:
if (reply) {
sb = reply->header.getByName(format->header);
- str = sb.buf();
+ str = sb.unsafeBuf();
}
break;
case _external_acl_format::EXT_ACL_HEADER_REPLY_ID:
if (reply) {
sb = reply->header.getStrOrList(format->header_id);
- str = sb.buf();
+ str = sb.unsafeBuf();
}
break;
case _external_acl_format::EXT_ACL_HEADER_REPLY_MEMBER:
if (reply) {
sb = reply->header.getByNameListMember(format->header, format->member, format->separator);
- str = sb.buf();
+ str = sb.unsafeBuf();
}
break;
case _external_acl_format::EXT_ACL_HEADER_REPLY_ID_MEMBER:
if (reply) {
sb = reply->header.getListMember(format->header_id, format->member, format->separator);
- str = sb.buf();
+ str = sb.unsafeBuf();
}
break;
#if USE_SSL
#endif
case _external_acl_format::EXT_ACL_EXT_USER:
- str = request->extacl_user.buf();
+ str = request->extacl_user.unsafeBuf();
break;
case _external_acl_format::EXT_ACL_UNKNOWN:
if (entry != NULL) {
debugs(82, 4, "externalAclLookup: entry = { date=" <<
(long unsigned int) entry->date << ", result=" <<
- entry->result << ", user=" << entry->user.buf() << " tag=" <<
- entry->tag.buf() << " log=" << entry->log.buf() << " }");
+ entry->result << ", user=" << entry->user.unsafeBuf() << " tag=" <<
+ entry->tag.unsafeBuf() << " log=" << entry->log.unsafeBuf() << " }");
}
if (!stripe_path) {
String result = path;
result.append("/stripe");
- const_cast<CossSwapDir *>(this)->stripe_path = xstrdup(result.buf());
+ const_cast<CossSwapDir *>(this)->stripe_path = xstrdup(result.unsafeBuf());
}
return stripe_path;
wordlist *w;
char *dirup;
int i, j, k;
- const char *title = title_url.buf();
+ const char *title = title_url.unsafeBuf();
flags.listing_started = true;
printfReplyBody("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
printfReplyBody("<!-- HTML listing generated by Squid %s -->\n",
if (flags.need_base_href)
printfReplyBody("<BASE HREF=\"%s\">\n",
- html_quote(base_href.buf()));
+ html_quote(base_href.unsafeBuf()));
printfReplyBody("</HEAD><BODY>\n");
if (flags.dir_slash) {
url = xstrdup("./");
} else {
- const char *title = title_url.buf();
+ const char *title = title_url.unsafeBuf();
int k = 6 + strcspn(&title[6], "/");
char *t;
url = xstrdup(title + k);
FtpStateData::parseListing()
{
char *buf = data.readBuf->content();
- char *sbuf; /* NULL-terminated copy of buf */
+ char *sbuf; /* NULL-terminated copy of unsafeBuf */
char *end;
char *line;
char *s;
/* UNIX root directory */
flags.isdir = 1;
flags.root_dir = 1;
- } else if ((l >= 1) && (*(request->urlpath.buf() + l - 1) == '/')) {
+ } else if ((l >= 1) && (*(request->urlpath.unsafeBuf() + l - 1) == '/')) {
/* Directory URL, ending in / */
flags.isdir = 1;
checkUrlpath();
buildTitleUrl();
debugs(9, 5, HERE << "host=" << request->GetHost() << ", path=" <<
- request->urlpath.buf() << ", user=" << user << ", passwd=" <<
+ request->urlpath.unsafeBuf() << ", user=" << user << ", passwd=" <<
password);
state = BEGIN;
mode = 'A';
} else {
t = ftpState->request->urlpath.rpos('/');
- filename = t ? t + 1 : ftpState->request->urlpath.buf();
+ filename = t ? t + 1 : ftpState->request->urlpath.unsafeBuf();
mode = mimeGetTransferMode(filename);
}
debugs(9, 3, HERE);
if (code == 200) {
- p = path = xstrdup(ftpState->request->urlpath.buf());
+ p = path = xstrdup(ftpState->request->urlpath.unsafeBuf());
if (*p == '/')
p++;
if (ftpState->theSize == 0) {
debugs(9, 2, "SIZE reported " <<
ftpState->ctrl.last_reply << " on " <<
- ftpState->title_url.buf());
+ ftpState->title_url.unsafeBuf());
ftpState->theSize = -1;
}
} else if (code < 0) {
safe_free(ftpState->filepath);
/* Build the new path (urlpath begins with /) */
- path = xstrdup(ftpState->request->urlpath.buf());
+ path = xstrdup(ftpState->request->urlpath.unsafeBuf());
rfc1738_unescape(path);
e->buffer(); /* released when done processing current data payload */
- filename = (t = urlpath.rpos('/')) ? t + 1 : urlpath.buf();
+ filename = (t = urlpath.rpos('/')) ? t + 1 : urlpath.unsafeBuf();
if (flags.isdir) {
mime_type = "text/html";
if (request->protocol != PROTO_FTP)
return NULL;
- if ( !strncmp(request->urlpath.buf(), "/", 1) ) {
+ if ( !strncmp(request->urlpath.unsafeBuf(), "/", 1) ) {
newbuf.append(request->urlpath);
request->urlpath.absorb(newbuf);
safe_free(request->canonical);
- } else if ( !strncmp(request->urlpath.buf(), "%2f", 3) ) {
- newbuf.append(request->urlpath.buf() +1);
+ } else if ( !strncmp(request->urlpath.unsafeBuf(), "%2f", 3) ) {
+ newbuf.append(request->urlpath.unsafeBuf() +1);
request->urlpath.absorb(newbuf);
safe_free(request->canonical);
}
static void
gopher_request_parse(const HttpRequest * req, char *type_id, char *request)
{
- const char *path = req->urlpath.buf();
+ const char *path = req->urlpath.unsafeBuf();
if (request)
request[0] = '\0';
} /* while loop */
if (outbuf.size() > 0) {
- entry->append(outbuf.buf(), outbuf.size());
+ entry->append(outbuf.unsafeBuf(), outbuf.size());
/* now let start sending stuff to client */
entry->flush();
}
do_next_read = 0;
} else if (len == 0) {
/* Connection closed; retrieval done. */
- /* flush the rest of data in temp buf if there is one. */
+ /* flush the rest of data in temp unsafeBuf if there is one. */
if (gopherState->conversion != gopher_ds::NORMAL)
gopherEndHTML(gopherState);
const char *url;
if (_peer->options.originserver)
- url = orig_request->urlpath.buf();
+ url = orig_request->urlpath.unsafeBuf();
else
url = entry->url();
strListAdd(&vstr, name, ',');
hdr = request->header.getByName(name);
safe_free(name);
- value = hdr.buf();
+ value = hdr.unsafeBuf();
if (value) {
value = rfc1738_escape_part(value);
strListAdd(&vstr, name, ',');
hdr = request->header.getByName(name);
safe_free(name);
- value = hdr.buf();
+ value = hdr.unsafeBuf();
if (value) {
value = rfc1738_escape_part(value);
vary.clean();
#endif
- debugs(11, 3, "httpMakeVaryMark: " << vstr.buf());
- return vstr.buf();
+ debugs(11, 3, "httpMakeVaryMark: " << vstr.unsafeBuf());
+ return vstr.unsafeBuf();
}
void
header = hdr->getStrOrList(HDR_PROXY_SUPPORT);
/* XXX This ought to be done in a case-insensitive manner */
- rc = (strstr(header.buf(), "Session-Based-Authentication") != NULL);
+ rc = (strstr(header.unsafeBuf(), "Session-Based-Authentication") != NULL);
return rc;
}
*/
/*
void
-HttpStateData::ReadReplyWrapper(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *data)
+HttpStateData::ReadReplyWrapper(int fd, char *unsafeBuf, size_t len, comm_err_t flag, int xerrno, void *data)
{
HttpStateData *httpState = static_cast<HttpStateData *>(data);
assert (fd == httpState->fd);
- // assert(buf == readBuf->content());
+ // assert(unsafeBuf == readBuf->content());
PROF_start(HttpStateData_readReply);
httpState->readReply (len, flag, xerrno);
PROF_stop(HttpStateData_readReply);
if (!flags.headers_parsed && len > 0 && fd_table[fd].uses > 1) {
/* Skip whitespace between replies */
- while (len > 0 && xisspace(*buf))
- xmemmove(buf, buf + 1, len--);
+ while (len > 0 && xisspace(*unsafeBuf))
+ xmemmove(unsafeBuf, unsafeBuf + 1, len--);
if (len == 0) {
/* Continue to read... */
orig_request->http_ver.major,
orig_request->http_ver.minor, ThisCache);
strListAdd(&strVia, bbuf, ',');
- hdr_out->putStr(HDR_VIA, strVia.buf());
+ hdr_out->putStr(HDR_VIA, strVia.unsafeBuf());
strVia.clean();
}
snprintf(bbuf, BBUF_SZ, "%s=\"Surrogate/1.0 ESI/1.0\"",
Config.Accel.surrogate_id);
strListAdd(&strSurrogate, bbuf, ',');
- hdr_out->putStr(HDR_SURROGATE_CAPABILITY, strSurrogate.buf());
+ hdr_out->putStr(HDR_SURROGATE_CAPABILITY, strSurrogate.unsafeBuf());
}
#endif
strFwd = orig_request->client_addr.NtoA(ntoabuf, MAX_IPSTRLEN);
}
if (strFwd.size() > 0)
- hdr_out->putStr(HDR_X_FORWARDED_FOR, strFwd.buf());
+ hdr_out->putStr(HDR_X_FORWARDED_FOR, strFwd.unsafeBuf());
}
/** If set to DELETE - do not copy through. */
strFwd.clean();
const char *username = "-";
if (orig_request->extacl_user.size())
- username = orig_request->extacl_user.buf();
+ username = orig_request->extacl_user.unsafeBuf();
else if (orig_request->auth_user_request)
username = orig_request->auth_user_request->username();
} else if (strcmp(orig_request->peer_login, "PASS") == 0) {
if (orig_request->extacl_user.size() && orig_request->extacl_passwd.size()) {
char loginbuf[256];
- snprintf(loginbuf, sizeof(loginbuf), "%s:%s", orig_request->extacl_user.buf(), orig_request->extacl_passwd.buf());
+ snprintf(loginbuf, sizeof(loginbuf), "%s:%s", orig_request->extacl_user.unsafeBuf(), orig_request->extacl_passwd.unsafeBuf());
httpHeaderPutStrf(hdr_out, HDR_PROXY_AUTHORIZATION, "Basic %s",
base64_encode(loginbuf));
}
hdr_out->putStr(HDR_AUTHORIZATION, auth);
} else if (orig_request->extacl_user.size() && orig_request->extacl_passwd.size()) {
char loginbuf[256];
- snprintf(loginbuf, sizeof(loginbuf), "%s:%s", orig_request->extacl_user.buf(), orig_request->extacl_passwd.buf());
+ snprintf(loginbuf, sizeof(loginbuf), "%s:%s", orig_request->extacl_user.unsafeBuf(), orig_request->extacl_passwd.unsafeBuf());
httpHeaderPutStrf(hdr_out, HDR_AUTHORIZATION, "Basic %s",
base64_encode(loginbuf));
}
if (orig_request->auth_user_request)
username = orig_request->auth_user_request->username();
else if (orig_request->extacl_user.size())
- username = orig_request->extacl_user.buf();
+ username = orig_request->extacl_user.unsafeBuf();
snprintf(loginbuf, sizeof(loginbuf), "%s%s", username, orig_request->peer_login + 1);
httpHdrCcSetMaxAge(cc, getMaxAge(url));
if (request->urlpath.size())
- assert(strstr(url, request->urlpath.buf()));
+ assert(strstr(url, request->urlpath.unsafeBuf()));
}
/* Enforce sibling relations */
void
copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, String strConnection, HttpRequest * request, HttpRequest * orig_request, HttpHeader * hdr_out, int we_do_ranges, http_state_flags flags)
{
- debugs(11, 5, "httpBuildRequestHeader: " << e->name.buf() << ": " << e->value.buf());
+ debugs(11, 5, "httpBuildRequestHeader: " << e->name.unsafeBuf() << ": " << e->value.unsafeBuf());
if (!httpRequestHdrAllowed(e, &strConnection)) {
- debugs(11, 2, "'" << e->name.buf() << "' header denied by anonymize_headers configuration");
+ debugs(11, 2, "'" << e->name.unsafeBuf() << "' header denied by anonymize_headers configuration");
return;
}
HttpVersion httpver(1, 0);
mb->Printf("%s %s HTTP/%d.%d\r\n",
RequestMethodStr(request->method),
- request->urlpath.size() ? request->urlpath.buf() : "/",
+ request->urlpath.size() ? request->urlpath.unsafeBuf() : "/",
httpver.major,httpver.minor);
/* build and pack headers */
{
internalStart(HttpRequest * request, StoreEntry * entry)
{
ErrorState *err;
- const char *upath = request->urlpath.buf();
+ const char *upath = request->urlpath.unsafeBuf();
debugs(76, 3, "internalStart: " << request->client_addr << " requesting '" << upath << "'");
if (0 == strcmp(upath, "/squid-internal-dynamic/netdb")) {
{
eventAdd("peerDigestCheck", peerDigestCheck, pd, (double) delay, 1);
pd->times.next_check = squid_curtime + delay;
- debugs(72, 3, "peerDigestSetCheck: will check peer " << pd->host.buf() << " in " << delay << " secs");
+ debugs(72, 3, "peerDigestSetCheck: will check peer " << pd->host.unsafeBuf() << " in " << delay << " secs");
}
/*
peerDigestNotePeerGone(PeerDigest * pd)
{
if (pd->flags.requested) {
- debugs(72, 2, "peerDigest: peer " << pd->host.buf() << " gone, will destroy after fetch.");
+ debugs(72, 2, "peerDigest: peer " << pd->host.unsafeBuf() << " gone, will destroy after fetch.");
/* do nothing now, the fetching chain will notice and take action */
} else {
- debugs(72, 2, "peerDigest: peer " << pd->host.buf() << " is gone, destroying now.");
+ debugs(72, 2, "peerDigest: peer " << pd->host.unsafeBuf() << " is gone, destroying now.");
peerDigestDestroy(pd);
}
}
/* per-peer limit */
if (req_time - pd->times.received < PeerDigestReqMinGap) {
- debugs(72, 2, "peerDigestCheck: " << pd->host.buf() <<
+ debugs(72, 2, "peerDigestCheck: " << pd->host.unsafeBuf() <<
", avoiding close peer requests (" <<
(int) (req_time - pd->times.received) << " < " <<
(int) PeerDigestReqMinGap << " secs).");
/* global limit */
if (req_time - pd_last_req_time < GlobDigestReqMinGap) {
- debugs(72, 2, "peerDigestCheck: " << pd->host.buf() <<
+ debugs(72, 2, "peerDigestCheck: " << pd->host.unsafeBuf() <<
", avoiding close requests (" <<
(int) (req_time - pd_last_req_time) << " < " <<
(int) GlobDigestReqMinGap << " secs).");
assert(reply);
assert (reply->sline.status != 0);
status = reply->sline.status;
- debugs(72, 3, "peerDigestFetchReply: " << pd->host.buf() << " status: " << status <<
+ debugs(72, 3, "peerDigestFetchReply: " << pd->host.unsafeBuf() << " status: " << status <<
", expires: " << (long int) reply->expires << " (" << std::showpos <<
(int) (reply->expires - squid_curtime) << ")");
assert (fetch->entry->getReply()->sline.status != 0);
if (fetch->entry->getReply()->sline.status != HTTP_OK) {
- debugs(72, 1, "peerDigestSwapInHeaders: " << fetch->pd->host.buf() <<
+ debugs(72, 1, "peerDigestSwapInHeaders: " << fetch->pd->host.unsafeBuf() <<
" status " << fetch->entry->getReply()->sline.status <<
" got cached!");
#endif
else
- host = pd->host.buf();
+ host = pd->host.unsafeBuf();
}
debugs(72, 6, step_name << ": peer " << host << ", offset: " <<
peerDigestFetchStop(DigestFetchState * fetch, char *buf, const char *reason)
{
assert(reason);
- debugs(72, 2, "peerDigestFetchStop: peer " << fetch->pd->host.buf() << ", reason: " << reason);
+ debugs(72, 2, "peerDigestFetchStop: peer " << fetch->pd->host.unsafeBuf() << ", reason: " << reason);
peerDigestReqFinish(fetch, buf, 1, 1, 1, reason, 0);
}
peerDigestFetchAbort(DigestFetchState * fetch, char *buf, const char *reason)
{
assert(reason);
- debugs(72, 2, "peerDigestFetchAbort: peer " << fetch->pd->host.buf() << ", reason: " << reason);
+ debugs(72, 2, "peerDigestFetchAbort: peer " << fetch->pd->host.unsafeBuf() << ", reason: " << reason);
peerDigestReqFinish(fetch, buf, 1, 1, 1, reason, 1);
}
peerDigestPDFinish(DigestFetchState * fetch, int pcb_valid, int err)
{
PeerDigest *pd = fetch->pd;
- const char *host = pd->host.buf();
+ const char *host = pd->host.unsafeBuf();
pd->times.received = squid_curtime;
pd->times.req_delay = fetch->resp_time;
{
StoreDigestCBlock cblock;
int freed_size = 0;
- const char *host = pd->host.buf();
+ const char *host = pd->host.unsafeBuf();
xmemcpy(&cblock, buf, sizeof(cblock));
/* network -> host conversions */
const int bit_util = cacheDigestBitUtil(pd->cd);
if (bit_util > 65) {
- debugs(72, 0, "Warning: " << pd->host.buf() <<
+ debugs(72, 0, "Warning: " << pd->host.unsafeBuf() <<
" peer digest has too many bits on (" << bit_util << "%%).");
return 0;
assert(pd);
- const char *host = pd->host.buf();
+ const char *host = pd->host.unsafeBuf();
storeAppendPrintf(e, "\npeer digest from %s\n", host);
cacheDigestGuessStatsReport(&pd->stats.guess, e, host);
if (http->request->auth_user_request)
r->client_ident = http->request->auth_user_request->username();
- else if (http->request->extacl_user.buf() != NULL) {
- r->client_ident = http->request->extacl_user.buf();
+ else if (http->request->extacl_user.unsafeBuf() != NULL) {
+ r->client_ident = http->request->extacl_user.unsafeBuf();
}
if (!r->client_ident && (conn != NULL && conn->rfc931[0]))
if (http->request->auth_user_request)
p = http->request->auth_user_request->username();
- else if (http->request->extacl_user.buf() != NULL) {
- p = http->request->extacl_user.buf();
+ else if (http->request->extacl_user.unsafeBuf() != NULL) {
+ p = http->request->extacl_user.unsafeBuf();
}
if (!p && (conn != NULL && conn->rfc931[0]))
if (vary.size()) {
/* Again, we own this structure layout */
- rep->header.putStr(HDR_VARY, vary.buf());
+ rep->header.putStr(HDR_VARY, vary.unsafeBuf());
vary.clean();
}
(int) reply->date,
(int) reply->last_modified,
(int) reply->expires,
- reply->content_type.size() ? reply->content_type.buf() : "unknown",
+ reply->content_type.size() ? reply->content_type.unsafeBuf() : "unknown",
reply->content_length,
e->contentLen(),
RequestMethodStr(mem->method),
printf("Actual Text:\n");
/* TODO: these should really be just [] lookups, but String doesn't have those here yet. */
for ( int i = 0; i < anEntry->_appended_text.size(); i++) {
- CPPUNIT_ASSERT( expect.buf()[i] );
- CPPUNIT_ASSERT( anEntry->_appended_text.buf()[i] );
+ CPPUNIT_ASSERT( expect.unsafeBuf()[i] );
+ CPPUNIT_ASSERT( anEntry->_appended_text.unsafeBuf()[i] );
/* slight hack to make special chars visible */
- switch (anEntry->_appended_text.buf()[i]) {
+ switch (anEntry->_appended_text.unsafeBuf()[i]) {
case '\t':
printf("\\t");
break;
default:
- printf("%c", anEntry->_appended_text.buf()[i] );
+ printf("%c", anEntry->_appended_text.unsafeBuf()[i] );
}
/* make this an int comparison, so that we can see the ASCII code at failure */
- CPPUNIT_ASSERT_EQUAL( (int)expect.buf()[i], (int)anEntry->_appended_text.buf()[i] );
+ CPPUNIT_ASSERT_EQUAL( (int)expect.unsafeBuf()[i], (int)anEntry->_appended_text.unsafeBuf()[i] );
}
printf("\n");
CPPUNIT_ASSERT_EQUAL( expect, anEntry->_appended_text);
EBIT_CLR(e->flags, KEY_PRIVATE);
e->ping_status = PING_NONE;
EBIT_CLR(e->flags, ENTRY_VALIDATED);
- e->hashInsert((const cache_key *)name.buf()); /* do it after we clear KEY_PRIVATE */
+ e->hashInsert((const cache_key *)name.unsafeBuf()); /* do it after we clear KEY_PRIVATE */
return e;
}
EBIT_CLR(e->flags, KEY_PRIVATE);
e->ping_status = PING_NONE;
EBIT_CLR(e->flags, ENTRY_VALIDATED);
- e->hashInsert((const cache_key *)name.buf()); /* do it after we clear KEY_PRIVATE */
+ e->hashInsert((const cache_key *)name.unsafeBuf()); /* do it after we clear KEY_PRIVATE */
return e;
}
return request->canonical;
if (request->protocol == PROTO_URN) {
- snprintf(urlbuf, MAX_URL, "urn:%s", request->urlpath.buf());
+ snprintf(urlbuf, MAX_URL, "urn:%s", request->urlpath.unsafeBuf());
} else {
/// \todo AYJ: this could use "if..else and method == METHOD_CONNECT" easier.
switch (request->method.id()) {
*request->login ? "@" : null_string,
request->GetHost(),
portbuf,
- request->urlpath.buf());
+ request->urlpath.unsafeBuf());
break;
}
char *t;
if (request->protocol == PROTO_URN) {
- snprintf(buf, MAX_URL, "urn:%s", request->urlpath.buf());
+ snprintf(buf, MAX_URL, "urn:%s", request->urlpath.unsafeBuf());
} else {
/// \todo AYJ: this could use "if..else and method == METHOD_CONNECT" easier.
switch (request->method.id()) {
loginbuf,
request->GetHost(),
portbuf,
- request->urlpath.buf());
+ request->urlpath.unsafeBuf());
/*
* strip arguments AFTER a question-mark
*/
char *urlbuf = (char *)xmalloc(MAX_URL * sizeof(char));
if (req->protocol == PROTO_URN) {
- snprintf(urlbuf, MAX_URL, "urn:%s", req->urlpath.buf());
+ snprintf(urlbuf, MAX_URL, "urn:%s", req->urlpath.unsafeBuf());
return (urlbuf);
}
if (relUrl[0] == '/') {
strncpy(&urlbuf[urllen], relUrl, MAX_URL - urllen - 1);
} else {
- const char *path = req->urlpath.buf();
+ const char *path = req->urlpath.unsafeBuf();
const char *last_slash = strrchr(path, '/');
if (last_slash == NULL) {
if ((t = urlpath.pos(':')) != NULL) {
urlpath.set(t, '\0');
- result = xstrdup(urlpath.buf());
+ result = xstrdup(urlpath.unsafeBuf());
urlpath.set(t, ':');
} else {
- result = xstrdup(urlpath.buf());
+ result = xstrdup(urlpath.unsafeBuf());
}
return result;
bool
UrnState::RequestNeedsMenu(HttpRequest *r)
{
- return strncasecmp(r->urlpath.buf(), "menu.", 5) == 0;
+ return strncasecmp(r->urlpath.unsafeBuf(), "menu.", 5) == 0;
}
void
{
LOCAL_ARRAY(char, local_urlres, 4096);
char *host = getHost (uri);
- snprintf(local_urlres, 4096, "http://%s/uri-res/N2L?urn:%s", host, uri.buf());
+ snprintf(local_urlres, 4096, "http://%s/uri-res/N2L?urn:%s", host, uri.unsafeBuf());
safe_free (host);
safe_free (urlres);
urlres = xstrdup (local_urlres);
UrnState::setUriResFromRequest(HttpRequest *r)
{
if (RequestNeedsMenu(r)) {
- updateRequestURL(r, r->urlpath.buf() + 5);
+ updateRequestURL(r, r->urlpath.unsafeBuf() + 5);
flags.force_menu = 1;
}
buf = (char *)xmalloc(l);
- snprintf(buf, l, "%s\r\n", p->request->urlpath.buf() + 1);
+ snprintf(buf, l, "%s\r\n", p->request->urlpath.unsafeBuf() + 1);
comm_write(fd, buf, strlen(buf), whoisWriteComplete, p, NULL);
comm_read(fd, p->buf, BUFSIZ, whoisReadReply, p);