]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Refactoring: renamed String::buf() to unsafeBuf().
authorFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 29 Jan 2009 14:50:26 +0000 (15:50 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Thu, 29 Jan 2009 14:50:26 +0000 (15:50 +0100)
Introduced aliases for it named String::rawBuf() and String::termedBuf().
Introduced String::defined() and String::undefined().

52 files changed:
src/ACLExtUser.cc
src/ACLHTTPHeaderData.cc
src/ACLUrlPath.cc
src/CommonPool.h
src/DelayTagged.cc
src/DiskIO/AIO/AIODiskFile.cc
src/ESI.cc
src/ESIVarState.cc
src/HttpHdrCc.cc
src/HttpHdrExtField.cc
src/HttpHdrRange.cc
src/HttpHdrSc.cc
src/HttpHdrScTarget.cc
src/HttpHeader.cc
src/HttpHeaderTools.cc
src/HttpReply.cc
src/HttpRequest.cc
src/HttpRequestMethod.cc
src/ICAP/ICAPModXact.cc
src/ICAP/ICAPOptions.cc
src/ICAP/ICAPServiceRep.cc
src/ICAP/ICAPXaction.cc
src/LoadableModule.cc
src/SquidString.h
src/String.cc
src/String.cci
src/access_log.cc
src/adaptation/Config.cc
src/adaptation/ServiceConfig.cc
src/client_side.cc
src/client_side_reply.cc
src/client_side_request.cc
src/eCAP/MessageRep.cc
src/eCAP/ServiceRep.cc
src/errorpage.cc
src/external_acl.cc
src/fs/coss/store_dir_coss.cc
src/ftp.cc
src/gopher.cc
src/http.cc
src/internal.cc
src/peer_digest.cc
src/redirect.cc
src/stat.cc
src/store.cc
src/store_log.cc
src/tests/testEvent.cc
src/tests/testStoreController.cc
src/tests/testStoreHashIndex.cc
src/url.cc
src/urn.cc
src/whois.cc

index f8570809cce43a915b672dcb9b28935b3be091bc..bbdbb08df095a86d0cd887385af564ed565066e2 100644 (file)
@@ -79,7 +79,7 @@ int
 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;
     }
index ec785606d77f392f1b44c328cb91ec7d7e621d70..3bfd75d12244d662c09a112d6f622d3f296427a4 100644 (file)
@@ -63,18 +63,18 @@ ACLHTTPHeaderData::match(HttpHeader* hdr)
     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(&regex_dump);
@@ -87,14 +87,14 @@ ACLHTTPHeaderData::parse()
     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*> *
index 7ca0ba1bcc666c1d7c4b19cf8a7986089690924c..a712d007b21d023781dce27d946511f365bbafbe 100644 (file)
@@ -47,7 +47,7 @@ ACLStrategised<char const *> ACLUrlPath::RegistryEntry_(new ACLRegexData, ACLUrl
 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);
index 7e763d3723f6e385b4b0e1a7f5eed135077189ee..281025e21828e6c1fbe503e1ce5c9ef6f7c36bd5 100644 (file)
@@ -59,7 +59,7 @@ public:
     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();
index f92250153108ffdf04df526ef69f22474156d8c5..a5c08e6041947d3627e8629d97fb64171c1bd7da 100644 (file)
@@ -77,7 +77,7 @@ int
 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
@@ -195,7 +195,7 @@ DelayTaggedBucket::~DelayTaggedBucket()
 void
 DelayTaggedBucket::stats (StoreEntry *entry) const
 {
-    storeAppendPrintf(entry, " %s:", tag.buf());
+    storeAppendPrintf(entry, " %s:", tag.unsafeBuf());
     theBucket.stats (entry);
 }
 
index 5d72e7a78360115538c1e55ead6693631eb90b3f..fd31fc1a1786dbf142385dde754b826f08a74a47 100644 (file)
@@ -87,10 +87,10 @@ AIODiskFile::open(int flags, mode_t mode, RefCount<IORequestor> callback)
 {
     /* 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;
@@ -130,7 +130,7 @@ AIODiskFile::read(ReadRequest *request)
         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;
     }
 
@@ -167,7 +167,7 @@ AIODiskFile::read(ReadRequest *request)
         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);
     }
 
 }
@@ -188,7 +188,7 @@ AIODiskFile::write(WriteRequest *request)
         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;
     }
 
@@ -225,7 +225,7 @@ AIODiskFile::write(WriteRequest *request)
         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);
     }
 }
 
index 38a9fb58f76fddcfd169c002d3d37f3cb8ed7ac9..4962d5d85cb16b3af9676eb76f04bdf9432084cf 100644 (file)
@@ -1578,7 +1578,7 @@ esiLiteral::process (int dovars)
         /* Ensure variable state is clean */
 
         while (temp.getRaw()) {
-            varState->feedData(temp->buf,temp->len);
+            varState->feedData(temp->unsafeBuf,temp->len);
             temp = temp->next;
         }
 
index 1a160e06e33f40037bdea74b79903efbcbcab346..5d62752d1ef36607f0bf7b2deee93809604ec903 100644 (file)
@@ -317,7 +317,7 @@ ESIVarState::ESIVarState (HttpHeader const *aHeader, char const *uri)
 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 */
@@ -434,7 +434,7 @@ ESIVariableCookie::eval (ESIVarState &state, char const *subref, char const *fou
             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));
         }
@@ -468,7 +468,7 @@ ESIVariableLanguage::eval (ESIVarState &state, char const *subref, char const *f
     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";
@@ -884,7 +884,7 @@ ESIVarState::buildVary (HttpReply *rep)
 
     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);
     }
 }
index ceac343453c93a8040d2c7873e35f78d6ed5c8a1..c489af347e6529b803177dfb5c50508f8a726747 100644 (file)
@@ -134,13 +134,13 @@ httpHdrCcParseInit(HttpHdrCc * cc, const String * str)
                 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++;
 
@@ -205,7 +205,7 @@ httpHdrCcDestroy(HttpHdrCc * cc)
 {
     assert(cc);
 
-    if (cc->other.buf())
+    if (cc->other.unsafeBuf())
         cc->other.clean();
 
     memFree(cc, MEM_HTTP_HDR_CC);
@@ -235,7 +235,7 @@ httpHdrCcPackInto(const HttpHdrCc * cc, Packer * p)
         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 */
 
@@ -253,7 +253,7 @@ httpHdrCcPackInto(const HttpHdrCc * cc, Packer * p)
     }
 
     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 */
@@ -299,7 +299,7 @@ httpHdrCcStatDumper(StoreEntry * sentry, int idx, double val, double size, int c
     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",
index 04e6708ed101b1bcddcf6308d0e84e53ba5373c8..c4a5678a5252f212f4c315acc973de9c22b1f4a4 100644 (file)
@@ -96,6 +96,6 @@ httpHdrExtFieldDup(HttpHdrExtField * f)
 {
     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());
 }
index 78e59bbd0df6c6635297e7ad2bb87f61c4fc9b9a..6045a996a6d0db8bfe84866345fc2e29040c0917 100644 (file)
@@ -251,14 +251,14 @@ HttpHdrRange::parseInit(const String * range_spec)
     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)) {
index a7adaadd64b7a6421bd10bada3a5b69bbbebe2ee..537387f0c092c24f298b144ca8a3aa5f1e18cd26 100644 (file)
@@ -138,7 +138,7 @@ httpHdrScParseInit(HttpHdrSc * sc, const String * str)
                                   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;
         }
 
@@ -162,7 +162,7 @@ httpHdrScParseInit(HttpHdrSc * sc, const String * str)
 
         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++;
 
@@ -257,7 +257,7 @@ httpHdrScTargetPackInto(const HttpHdrScTarget * sc, Packer * p)
         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 */
 
@@ -265,14 +265,14 @@ httpHdrScTargetPackInto(const HttpHdrScTarget * sc, Packer * p)
                 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
@@ -339,7 +339,7 @@ httpHdrScTargetStatDumper(StoreEntry * sentry, int idx, double val, double size,
     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",
@@ -352,7 +352,7 @@ httpHdrScStatDumper(StoreEntry * sentry, int idx, double val, double size, int c
     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",
@@ -369,9 +369,9 @@ httpHdrScFindTarget (HttpHdrSc *sc, const char *target)
     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;
index b011c47774572c38696e26867355013bca365e89..5f3906e8d28c917b14328d87676f6e10415d860b 100644 (file)
@@ -68,7 +68,7 @@ httpHdrScTargetDup(const HttpHdrScTarget * sc)
 {
     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;
index be38e5b90acc1013c4f89129020a3922cc5b7119..cad06c8f3113cd4153aa0a8e7557d965e75df98b 100644 (file)
@@ -461,7 +461,7 @@ HttpHeader::update (HttpHeader const *fresh, HttpHeaderMask const *denied_mask)
         if (e->id != HDR_OTHER)
             delById(e->id);
         else
-            delByName(e->name.buf());
+            delByName(e->name.unsafeBuf());
     }
 
     pos = HttpHeaderInitPos;
@@ -578,7 +578,7 @@ HttpHeader::parse(const char *header_start, const char *header_end)
         }
 
         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) << "}");
@@ -588,12 +588,12 @@ HttpHeader::parse(const char *header_start, const char *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);
@@ -615,7 +615,7 @@ HttpHeader::parse(const char *header_start, const char *header_end)
             }
         }
 
-        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) << "}");
@@ -875,7 +875,7 @@ HttpHeader::getList(http_hdr_type id, String *s) const
 
     while ((e = getEntry(&pos))) {
         if (e->id == id)
-            strListAdd(s, e->value.buf(), ',');
+            strListAdd(s, e->value.unsafeBuf(), ',');
     }
 
     /*
@@ -909,7 +909,7 @@ HttpHeader::getList(http_hdr_type id) const
 
     while ((e = getEntry(&pos))) {
         if (e->id == id)
-            strListAdd(&s, e->value.buf(), ',');
+            strListAdd(&s, e->value.unsafeBuf(), ',');
     }
 
     /*
@@ -964,7 +964,7 @@ HttpHeader::getByName(const char *name) const
     /* 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(), ',');
         }
     }
 
@@ -1209,7 +1209,7 @@ HttpHeader::getTime(http_hdr_type id) const
     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);
     }
 
@@ -1226,7 +1226,7 @@ HttpHeader::getStr(http_hdr_type id) const
 
     if ((e = findEntry(id))) {
         httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
-        return e->value.buf();
+        return e->value.unsafeBuf();
     }
 
     return NULL;
@@ -1242,7 +1242,7 @@ HttpHeader::getLastStr(http_hdr_type id) const
 
     if ((e = findLastEntry(id))) {
         httpHeaderNoteParsedEntry(e->id, e->value, 0); /* no errors are possible */
-        return e->value.buf();
+        return e->value.unsafeBuf();
     }
 
     return NULL;
@@ -1322,7 +1322,7 @@ HttpHeader::getContRange() const
     HttpHeaderEntry *e;
 
     if ((e = findEntry(HDR_CONTENT_RANGE))) {
-        cr = httpHdrContRangeParseCreate(e->value.buf());
+        cr = httpHdrContRangeParseCreate(e->value.unsafeBuf());
         httpHeaderNoteParsedEntry(e->id, e->value, !cr);
     }
 
@@ -1367,7 +1367,7 @@ HttpHeader::getETag(http_hdr_type id) const
     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;
 }
@@ -1381,7 +1381,7 @@ HttpHeader::getTimeOrTag(http_hdr_type id) const
     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)) {
@@ -1417,13 +1417,13 @@ HttpHeaderEntry::HttpHeaderEntry(http_hdr_type anId, const char *aName, const ch
 
     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)
@@ -1503,7 +1503,7 @@ HttpHeaderEntry::parse(const char *field_start, const char *field_end)
 
     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();
@@ -1518,24 +1518,24 @@ HttpHeaderEntry::parse(const char *field_start, const char *field_end)
 
     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);
 }
 
@@ -1545,7 +1545,7 @@ HttpHeaderEntry::getInt() const
     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;
@@ -1559,7 +1559,7 @@ HttpHeaderEntry::getInt64() const
     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;
@@ -1574,7 +1574,7 @@ httpHeaderNoteParsedEntry(http_hdr_type id, String const &context, int error)
 
     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() << "'");
     }
 }
 
@@ -1591,7 +1591,7 @@ httpHeaderFieldStatDumper(StoreEntry * sentry, int idx, double val, double size,
 {
     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 */
 
@@ -1669,7 +1669,7 @@ httpHeaderStoreReport(StoreEntry * e)
     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));
     }
@@ -1690,7 +1690,7 @@ httpHeaderIdByName(const char *name, int name_len, const HttpHeaderFieldInfo * i
         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;
     }
@@ -1715,7 +1715,7 @@ httpHeaderNameById(int id)
 
     assert(id >= 0 && id < HDR_ENUM_END);
 
-    return Headers[id].name.buf();
+    return Headers[id].name.unsafeBuf();
 }
 
 int
@@ -1804,7 +1804,7 @@ HttpHeader::removeConnectionHeaderEntries()
 
         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)
index 289ccc8b89401a7ebd50dfd2035be583d9034634..6776898d8c09087100c92ea35b56f67944907e1b 100644 (file)
@@ -258,7 +258,7 @@ strListGetItem(const String * str, char del, const char **item, int *ilen, const
     delim[2][1] = del;
 
     if (!*pos) {
-        *pos = str->buf();
+        *pos = str->unsafeBuf();
 
         if (!*pos)
             return 0;
index f0fabc45f23fac5225be5a8b13c8e7c2b3fdbfd0..ad0f3af82d42938b68b061cf0f75ceffda94ee23 100644 (file)
@@ -281,7 +281,7 @@ HttpReply::validatorsMatch(HttpReply const * otherRep) const
 
     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;
@@ -295,7 +295,7 @@ HttpReply::validatorsMatch(HttpReply const * otherRep) const
 
     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;
@@ -440,7 +440,7 @@ HttpReply::bodySize(const HttpRequestMethod& method) const
 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;
     }
index f4b844ae532556468c583a8665698528b9444529..82aeea5cf2b88ff043da73cbf5531abd777ee3e2 100644 (file)
@@ -150,7 +150,7 @@ HttpRequest::reset()
 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();
@@ -299,7 +299,7 @@ HttpRequest::pack(Packer * p)
     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 */
@@ -336,7 +336,7 @@ httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConn)
     assert(e);
     /* check connection header */
 
-    if (strConn && strListIsMember(strConn, e->name.buf(), ','))
+    if (strConn && strListIsMember(strConn, e->name.unsafeBuf(), ','))
         return 0;
 
     return 1;
@@ -411,7 +411,7 @@ const char *HttpRequest::packableURI(bool full_uri) const
         return urlCanonical((HttpRequest*)this);
 
     if (urlpath.size())
-        return urlpath.buf();
+        return urlpath.unsafeBuf();
 
     return "/";
 }
index 633485efaef443578f9bd3c8bcd1411defcefe00..02b035f117b689e8f4e70aef510e5565fd5be722 100644 (file)
@@ -177,7 +177,7 @@ HttpRequestMethod::image() const
         return RequestMethodStr[theMethod];
     } else {
         if (theImage.size()>0) {
-            return theImage.buf();
+            return theImage.unsafeBuf();
         } else {
             return "METHOD_OTHER";
         }
index 5bb73260e3cc21f37c6fbd9b07d8d7a7e28416b8..e714eaaacb4e662e210a30869ba219b497c85529 100644 (file)
@@ -1040,11 +1040,11 @@ void ICAPModXact::makeRequestHeaders(MemBuf &buf)
     // 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: ");
 
@@ -1107,7 +1107,7 @@ void ICAPModXact::makeRequestHeaders(MemBuf &buf)
     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
 
@@ -1268,7 +1268,7 @@ void ICAPModXact::finishNullOrEmptyBodyPreview(MemBuf &buf)
     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());
@@ -1376,7 +1376,7 @@ void ICAPModXact::estimateVirginBody()
         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);
index f8e92161d091f86f75ad63d88efab3226c4c506b..5f30c245ee7fce237be4938dbae682bd23d892dd 100644 (file)
@@ -124,8 +124,8 @@ void ICAPOptions::cfgIntHeader(const HttpHeader *h, const char *fname, int &valu
 {
     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;
 
@@ -176,8 +176,8 @@ bool ICAPOptions::TransferList::matches(const String &urlPath) const
         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;
index bad4929ded821d67e980585e4e89aeebc84becee..b02276d86e98f3babbf23a412eeae35de0b00814 100644 (file)
@@ -279,8 +279,8 @@ void ICAPServiceRep::checkOptions()
         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());
         }
     }
 
@@ -293,7 +293,7 @@ void ICAPServiceRep::checkOptions()
         // 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());
     }
 }
 
index 1be3a0ceb5735659d0d33cac8e691f2a1a580b59..45dce4ceb3b941a4c850baeb885d154480554565 100644 (file)
@@ -76,7 +76,7 @@ void ICAPXaction::openConnection()
         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);
 
@@ -96,12 +96,12 @@ void ICAPXaction::openConnection()
 
     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;
@@ -119,7 +119,7 @@ void ICAPXaction::openConnection()
     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);
 }
 
 /*
@@ -157,7 +157,7 @@ void ICAPXaction::closeConnection()
             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 {
@@ -232,7 +232,7 @@ void ICAPXaction::handleCommTimedout()
 {
     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();
 
@@ -295,7 +295,7 @@ void ICAPXaction::scheduleRead()
 
     /*
      * 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",
@@ -320,7 +320,7 @@ void ICAPXaction::noteCommRead(const CommIoCbParams &io)
 
     /*
      * 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) {
index fe18d8a820468df2adb941e3a57be82bf687464f..7209771669df501a98cbdc54a44ac155e9396db8 100644 (file)
@@ -67,7 +67,7 @@ void LoadableModule::unload()
 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);
index da176f000cd77f982f13f917ccbf2df889c4081b..c807ecbaf29a91d531a686e1c3e770acd78a0080 100644 (file)
@@ -98,7 +98,26 @@ public:
     _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);
index e083ead75ccb35ed8f91993a7f6946d67fa59a3a..b423424b139e4f0655cee943fc33e6af60f5e419 100644 (file)
@@ -81,7 +81,7 @@ String::operator = (String const &old)
 {
     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;
 }
 
@@ -128,7 +128,7 @@ String::allocAndFill(const char *str, int len)
 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);
@@ -141,7 +141,7 @@ String::clean()
     PROF_start(StringClean);
     assert(this);
 
-    if (buf())
+    if (unsafeBuf())
         memFreeString(size_, buf_);
 
     len_ = 0;
@@ -188,7 +188,7 @@ String::append(const char *str, int len)
         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);
@@ -219,7 +219,7 @@ String::append (char chr)
 void
 String::append(String const &old)
 {
-    append (old.buf(), old.len_);
+    append (old.unsafeBuf(), old.len_);
 }
 
 void
@@ -237,7 +237,7 @@ String::absorb(String &old)
 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 &
index 520f734535dfa9084b95e9121def99818a9af826..e0f3a90eb867183fbac0b1c6f8000fc5c66d551d 100644 (file)
@@ -49,7 +49,29 @@ String::size() const
 }
 
 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_;
 }
@@ -65,19 +87,19 @@ String::operator [](unsigned int pos)
 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
@@ -94,7 +116,7 @@ String::cmp (char const *aString) const
     if (aString == NULL || aString[0] == '\0')
         return 1;
 
-    return strcmp(buf(), aString);
+    return strcmp(unsafeBuf(), aString);
 }
 
 int
@@ -114,7 +136,7 @@ String::cmp (char const *aString, size_t count) const
     if (aString == NULL || aString[0] == '\0')
         return 1;
 
-    return strncmp(buf(), aString, count);
+    return strncmp(unsafeBuf(), aString, count);
 }
 
 int
@@ -131,19 +153,19 @@ String::cmp (String const &aString) const
     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
@@ -179,6 +201,6 @@ String::cutPointer(char const *loc)
 std::ostream &
 operator<<(std::ostream& os, String const &aString)
 {
-    os << aString.buf();
+    os << aString.unsafeBuf();
     return os;
 }
index 8b0f3dd7189da4724bd645c85ad9c9daa4da6114..4e95bd8fd96a3a54a7ed6fa1ac07e61c39d60b11 100644 (file)
@@ -625,7 +625,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
             if (al->request)
                 sb = al->request->header.getByName(fmt->data.header.header);
 
-            out = sb.buf();
+            out = sb.unsafeBuf();
 
             quote = 1;
 
@@ -635,7 +635,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
             if (al->reply)
                 sb = al->reply->header.getByName(fmt->data.header.header);
 
-            out = sb.buf();
+            out = sb.unsafeBuf();
 
             quote = 1;
 
@@ -645,7 +645,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
             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;
 
@@ -655,7 +655,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
             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;
 
@@ -764,7 +764,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
 
         case LFT_REQUEST_URLPATH:
             if (al->request) {
-                out = al->request->urlpath.buf();
+                out = al->request->urlpath.unsafeBuf();
                 quote = 1;
             }
             break;
@@ -810,7 +810,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
 
         case LFT_TAG:
             if (al->request)
-                out = al->request->tag.buf();
+                out = al->request->tag.unsafeBuf();
 
             quote = 1;
 
@@ -823,7 +823,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
 
         case LFT_EXT_LOG:
             if (al->request)
-                out = al->request->extacl_log.buf();
+                out = al->request->extacl_log.unsafeBuf();
 
             quote = 1;
 
index 993978a940f38b3f25d51af7b70a7a07c3c7ca6b..3adaef4ceab4ccabd69de8b4ee03f2e6089a2ed4 100644 (file)
@@ -68,8 +68,8 @@ Adaptation::Config::dumpService(StoreEntry *entry, const char *name) const
     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());
     }
 }
 
@@ -141,7 +141,7 @@ Adaptation::Config::DumpServiceSet(StoreEntry *entry, const char *name)
 {
     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
@@ -168,7 +168,7 @@ Adaptation::Config::DumpAccess(StoreEntry *entry, const char *name)
 
     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);
     }
 }
index 6188c30fdae308fd01c7255355ba7af1d45a61e8..dd8b81ecd8a90b788a5fd49faa58520d731a5bf7 100644 (file)
@@ -63,7 +63,7 @@ Adaptation::ServiceConfig::parse()
     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);
@@ -76,14 +76,14 @@ Adaptation::ServiceConfig::parse()
     // 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;
 
index 2dd1a45e624170e718b28dd1e4e649b33d3e1916..4b3d870dfd66eb41728ba89a5d0ba28c7671891b 100644 (file)
@@ -464,7 +464,7 @@ clientPrepareLogWithRequestDetails(HttpRequest * request, AccessLogEntry * aLogE
     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) {
 
@@ -486,10 +486,10 @@ ClientHttpRequest::logRequest()
 
         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 << "'");
@@ -852,7 +852,7 @@ ClientSocketContext::sendBody(HttpReply * rep, StoreIOBuffer bodyData)
 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);
 }
 
@@ -867,9 +867,9 @@ clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String
 
     /* 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 */
 
@@ -891,7 +891,7 @@ clientPackRangeHdr(const HttpReply * rep, const HttpHdrRangeSpec * spec, String
 }
 
 /**
- * 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
@@ -1170,7 +1170,7 @@ ClientSocketContext::buildRangeHeader(HttpReply * rep)
             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();
@@ -1924,7 +1924,7 @@ parseHttpRequest(ConnStateData *conn, HttpParser *hp, HttpRequestMethod * method
         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);
 
@@ -2271,11 +2271,11 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c
         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;
@@ -2623,7 +2623,7 @@ ConnStateData::handleReadData(char *buf, size_t size)
 }
 
 /**
- * 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
index f166aaa0c40d9d6a9041be3cfeb5de4ee2fe0eb3..1d8f9b57f4b36ca3d97ab55f2e165cba8407743c 100644 (file)
@@ -1291,7 +1291,7 @@ clientReplyContext::buildReplyHeader()
         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] == ' '))
@@ -1391,7 +1391,7 @@ clientReplyContext::buildReplyHeader()
                  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,
@@ -1671,7 +1671,7 @@ clientReplyDetach(clientStreamNode * node, ClientHttpRequest * http)
 }
 
 /*
- * 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
index cf8d0a6847231a16ac1ec303e5133840c2c8eb10..7b5a8556a3dcc84f6c284ab3c2aa9d96bab0a601 100644 (file)
@@ -426,7 +426,7 @@ clientFollowXForwardedForCheck(int answer, void *data)
         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();
 
         /*
@@ -851,7 +851,7 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
             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
@@ -892,7 +892,7 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
         }
 
 #if FORW_VIA_DB
-        fvdbCountVia(s.buf());
+        fvdbCountVia(s.unsafeBuf());
 
 #endif
 
@@ -918,7 +918,7 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
 
     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();
     }
 
@@ -1387,13 +1387,13 @@ ClientHttpRequest::noteMoreBodyDataAvailable(BodyPipe::Pointer)
     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();
     }
 
index 0f3eaf0abb27bea5e94a07d3db2c0d0712cab3fa..67291487eed95550c2078db5e69eca59906adc58 100644 (file)
@@ -39,7 +39,7 @@ Ecap::HeaderRep::value(const Name &name) const
     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
@@ -192,7 +192,7 @@ Ecap::RequestLineRep::uri(const Area &aUri)
 Ecap::RequestLineRep::Area
 Ecap::RequestLineRep::uri() const
 {
-    return Area::FromTempBuffer(theMessage.urlpath.buf(),
+    return Area::FromTempBuffer(theMessage.urlpath.unsafeBuf(),
                                 theMessage.urlpath.size());
 }
 
index c57c2975b518b17fed838865b3d676379efb6bc5..7bc0f4a6e375de144b742acbf253630c38de799c 100644 (file)
@@ -56,7 +56,7 @@ bool Ecap::ServiceRep::up() const
 bool Ecap::ServiceRep::wantsUrl(const String &urlPath) const
 {
     Must(up());
-    return theService->wantsUrl(urlPath.buf());
+    return theService->wantsUrl(urlPath.unsafeBuf());
 }
 
 Adaptation::Initiate *
index a9e0522ccc504ee2a95cd1d53c57bc7efb2bc3e4..4d0ec4317b9adb369b89697cf2abfe727fb40d89 100644 (file)
@@ -558,7 +558,7 @@ ErrorState::Dump(MemBuf * mb)
         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);
@@ -736,7 +736,7 @@ ErrorState::Convert(char token)
             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);
@@ -928,7 +928,7 @@ ErrorState::BuildContent()
      */
     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;
@@ -950,12 +950,12 @@ ErrorState::BuildContent()
              *  - 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') {
@@ -983,8 +983,8 @@ ErrorState::BuildContent()
             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 */
index 1585ba65f422820b5959bebe286b89c121e1a718..d27b551045a37c1889005f58637272db637ab602 100644 (file)
@@ -757,7 +757,7 @@ aclMatchExternal(external_acl_data *acl, ACLChecklist * ch)
 
     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);
 
@@ -885,7 +885,7 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data)
             break;
 
         case _external_acl_format::EXT_ACL_PATH:
-            str = request->urlpath.buf();
+            str = request->urlpath.unsafeBuf();
             break;
 
         case _external_acl_format::EXT_ACL_METHOD:
@@ -894,49 +894,49 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data)
 
         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
@@ -987,7 +987,7 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data)
 #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:
@@ -1336,8 +1336,8 @@ ACLExternal::ExternalAclLookup(ACLChecklist * ch, ACLExternal * me, EAH * callba
         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() << " }");
 
         }
 
index 90b5ff51ce4830fb7b3c68141fffdff2814ad2b0..2f193b5685acb96ea5fe229a82a7f90c0a56c128 100644 (file)
@@ -1175,7 +1175,7 @@ CossSwapDir::stripePath() const
     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;
index cbe509e56a25522df199590cef55e7b00f951800..15131808e762f5586ba9904e5cb9b719df844c17 100644 (file)
@@ -567,7 +567,7 @@ FtpStateData::listingStart()
     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",
@@ -586,7 +586,7 @@ FtpStateData::listingStart()
 
     if (flags.need_base_href)
         printfReplyBody("<BASE HREF=\"%s\">\n",
-                        html_quote(base_href.buf()));
+                        html_quote(base_href.unsafeBuf()));
 
     printfReplyBody("</HEAD><BODY>\n");
 
@@ -1013,7 +1013,7 @@ FtpStateData::htmlifyListEntry(const char *line)
             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);
@@ -1150,7 +1150,7 @@ void
 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;
@@ -1485,7 +1485,7 @@ FtpStateData::checkUrlpath()
         /* 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;
 
@@ -1574,7 +1574,7 @@ FtpStateData::start()
     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;
@@ -2025,7 +2025,7 @@ ftpSendType(FtpStateData * ftpState)
             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);
         }
 
@@ -2054,7 +2054,7 @@ ftpReadType(FtpStateData * ftpState)
     debugs(9, 3, HERE);
 
     if (code == 200) {
-        p = path = xstrdup(ftpState->request->urlpath.buf());
+        p = path = xstrdup(ftpState->request->urlpath.unsafeBuf());
 
         if (*p == '/')
             p++;
@@ -2308,7 +2308,7 @@ ftpReadSize(FtpStateData * ftpState)
         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) {
@@ -3396,7 +3396,7 @@ ftpTrySlashHack(FtpStateData * ftpState)
     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);
 
@@ -3640,7 +3640,7 @@ FtpStateData::appendSuccessHeader()
 
     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";
@@ -3753,12 +3753,12 @@ ftpUrlWith2f(HttpRequest * request)
     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);
     }
index 0ad9540dddeadcd32d2ea0187719fdffec8ab05f..bc6ae886885ae7b745d3f05be38dedf280a70876 100644 (file)
@@ -277,7 +277,7 @@ gopherMimeCreate(GopherStateData * gopherState)
 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';
@@ -751,7 +751,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
     }                          /* 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();
     }
@@ -853,7 +853,7 @@ gopherReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void
         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);
index 721ebd289c8d8594f8416e900b368aef9920b0dd..87bd35a95a07d82f862ba3fa411b95a0f3b3c736 100644 (file)
@@ -93,7 +93,7 @@ HttpStateData::HttpStateData(FwdState *theFwdState) : AsyncJob("HttpStateData"),
         const char *url;
 
         if (_peer->options.originserver)
-            url = orig_request->urlpath.buf();
+            url = orig_request->urlpath.unsafeBuf();
         else
             url = entry->url();
 
@@ -578,7 +578,7 @@ httpMakeVaryMark(HttpRequest * request, HttpReply const * reply)
         strListAdd(&vstr, name, ',');
         hdr = request->header.getByName(name);
         safe_free(name);
-        value = hdr.buf();
+        value = hdr.unsafeBuf();
 
         if (value) {
             value = rfc1738_escape_part(value);
@@ -603,7 +603,7 @@ httpMakeVaryMark(HttpRequest * request, HttpReply const * reply)
         strListAdd(&vstr, name, ',');
         hdr = request->header.getByName(name);
         safe_free(name);
-        value = hdr.buf();
+        value = hdr.unsafeBuf();
 
         if (value) {
             value = rfc1738_escape_part(value);
@@ -618,8 +618,8 @@ httpMakeVaryMark(HttpRequest * request, HttpReply const * reply)
     vary.clean();
 #endif
 
-    debugs(11, 3, "httpMakeVaryMark: " << vstr.buf());
-    return vstr.buf();
+    debugs(11, 3, "httpMakeVaryMark: " << vstr.unsafeBuf());
+    return vstr.unsafeBuf();
 }
 
 void
@@ -791,7 +791,7 @@ bool HttpStateData::peerSupportsConnectionPinning() const
 
     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;
 }
@@ -988,11 +988,11 @@ HttpStateData::persistentConnStatus() const
  */
 /*
 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);
@@ -1072,8 +1072,8 @@ HttpStateData::readReply (const CommIoCbParams &io)
     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... */
@@ -1454,7 +1454,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
                  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();
     }
 
@@ -1465,7 +1465,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
         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
 
@@ -1495,7 +1495,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
                 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();
@@ -1531,7 +1531,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
             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();
 
@@ -1542,7 +1542,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
         } 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));
             }
@@ -1569,7 +1569,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
                 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));
             }
@@ -1581,7 +1581,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
             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);
 
@@ -1613,7 +1613,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
             httpHdrCcSetMaxAge(cc, getMaxAge(url));
 
             if (request->urlpath.size())
-                assert(strstr(url, request->urlpath.buf()));
+                assert(strstr(url, request->urlpath.unsafeBuf()));
         }
 
         /* Enforce sibling relations */
@@ -1650,10 +1650,10 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
 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;
     }
 
@@ -1814,7 +1814,7 @@ HttpStateData::buildRequestPrefix(HttpRequest * request,
     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 */
     {
index 5ddd9c65b596d73fa56248974af81122ed276575..e3aec551dfba18669c4cc3968189d82e99326fff 100644 (file)
@@ -51,7 +51,7 @@ void
 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")) {
index 4a259bccf7f6cf1eeae5933d972fa199e8b6252b..450a0bff914203eaf7449e508d0c43481743d270 100644 (file)
@@ -231,7 +231,7 @@ peerDigestSetCheck(PeerDigest * pd, time_t delay)
 {
     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");
 }
 
 /*
@@ -241,10 +241,10 @@ void
 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);
     }
 }
@@ -279,7 +279,7 @@ peerDigestCheck(void *data)
     /* 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).");
@@ -289,7 +289,7 @@ peerDigestCheck(void *data)
 
     /* 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).");
@@ -544,7 +544,7 @@ peerDigestFetchReply(void *data, char *buf, ssize_t size)
         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) << ")");
 
@@ -634,7 +634,7 @@ peerDigestSwapInHeaders(void *data, char *buf, ssize_t size)
         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!");
 
@@ -762,7 +762,7 @@ peerDigestFetchedEnough(DigestFetchState * fetch, char *buf, ssize_t size, const
 #endif
 
         else
-            host = pd->host.buf();
+            host = pd->host.unsafeBuf();
     }
 
     debugs(72, 6, step_name << ": peer " << host << ", offset: " <<
@@ -813,7 +813,7 @@ static void
 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);
 }
 
@@ -822,7 +822,7 @@ static void
 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);
 }
 
@@ -872,7 +872,7 @@ static void
 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;
@@ -986,7 +986,7 @@ peerDigestSetCBlock(PeerDigest * pd, const char *buf)
 {
     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 */
@@ -1080,7 +1080,7 @@ peerDigestUseful(const PeerDigest * pd)
     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;
@@ -1106,7 +1106,7 @@ peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e)
 
     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);
index 7de349e4b2dc5386ae50e21f9ac7bf8c5087d18a..ab9e6a65eb25cd064eaa8ce875e14cd95693f6b6 100644 (file)
@@ -137,8 +137,8 @@ redirectStart(ClientHttpRequest * http, RH * handler, void *data)
 
     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]))
index 4c9e2a69c6a415e36f142ba7eaaa08da24f7e3e9..ef423864d4e938a6df54aa04ef215948e90300e0 100644 (file)
@@ -1653,8 +1653,8 @@ statClientRequests(StoreEntry * s)
 
         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]))
index 70ebeb4424a76b10ee00523ff2cf8c3a3f0f6af5..7317376273e94a50ecb4fd152080170ab27d7b72 100644 (file)
@@ -689,7 +689,7 @@ StoreEntry::setPublicKey()
 
             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();
             }
 
index 7392a1c448f2cfe205c0819a55b73c3376af02f0..2ab3acd5849217c20d21efc9f68beb508d8ac081 100644 (file)
@@ -86,7 +86,7 @@ storeLog(int tag, const StoreEntry * e)
                       (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),
index f59994dbe1df26edc10dbdf5aca308cc201a1a27..1305a84ebe8fb1b75f9f4c66c48e7c66c0934758 100644 (file)
@@ -98,19 +98,19 @@ testEvent::testDump()
     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);
index e5ebd6605329ee8b126a5ed6cffc185bd0bfa977..d9eb41f1065c9167ae937a9778e3b4e82b048b61 100644 (file)
@@ -111,7 +111,7 @@ addedEntry(StorePointer hashStore,
     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;
 }
 
index 44437a0cf3461f72cef0f85e5f7ef4023687d85d..9ab7597999d0a0c8a5a81e70927262c8c1b70389 100644 (file)
@@ -92,7 +92,7 @@ addedEntry(StorePointer hashStore,
     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;
 }
 
index e78e4baf7fed383318bccaab5ff5baeaac166dfa..dccad18851db063e491760f6ecd813d1a059e23c 100644 (file)
@@ -439,7 +439,7 @@ urlCanonical(HttpRequest * request)
         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()) {
@@ -460,7 +460,7 @@ urlCanonical(HttpRequest * request)
                      *request->login ? "@" : null_string,
                      request->GetHost(),
                      portbuf,
-                     request->urlpath.buf());
+                     request->urlpath.unsafeBuf());
 
             break;
         }
@@ -482,7 +482,7 @@ urlCanonicalClean(const HttpRequest * request)
     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()) {
@@ -515,7 +515,7 @@ urlCanonicalClean(const HttpRequest * request)
                      loginbuf,
                      request->GetHost(),
                      portbuf,
-                     request->urlpath.buf());
+                     request->urlpath.unsafeBuf());
             /*
              * strip arguments AFTER a question-mark
              */
@@ -584,7 +584,7 @@ urlMakeAbsolute(const HttpRequest * req, const char *relUrl)
     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);
     }
 
@@ -610,7 +610,7 @@ urlMakeAbsolute(const HttpRequest * req, const char *relUrl)
     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) {
index 08d99ccc47d860b4d4314895590c91503ff498c7..55f113113ea10694877bf2d58b45b438ea96013c 100644 (file)
@@ -174,10 +174,10 @@ UrnState::getHost (String &urlpath)
 
     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;
@@ -186,7 +186,7 @@ UrnState::getHost (String &urlpath)
 bool
 UrnState::RequestNeedsMenu(HttpRequest *r)
 {
-    return strncasecmp(r->urlpath.buf(), "menu.", 5) == 0;
+    return strncasecmp(r->urlpath.unsafeBuf(), "menu.", 5) == 0;
 }
 
 void
@@ -202,7 +202,7 @@ UrnState::createUriResRequest (String &uri)
 {
     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);
@@ -213,7 +213,7 @@ void
 UrnState::setUriResFromRequest(HttpRequest *r)
 {
     if (RequestNeedsMenu(r)) {
-        updateRequestURL(r, r->urlpath.buf() + 5);
+        updateRequestURL(r, r->urlpath.unsafeBuf() + 5);
         flags.force_menu = 1;
     }
 
index ff27261090ebe5b9cba792c637d7c8c89323ccc9..3eb3cfc3b3651c55792d865b1c41f1a5bb7c19e0 100644 (file)
@@ -98,7 +98,7 @@ whoisStart(FwdState * fwd)
 
     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);