]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Converted more unsafeBuf users.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 10 Feb 2009 11:02:53 +0000 (12:02 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 10 Feb 2009 11:02:53 +0000 (12:02 +0100)
12 files changed:
src/ACLExtUser.cc
src/DiskIO/AIO/AIODiskFile.cc
src/ESICustomParser.cc
src/ICAP/ICAPServiceRep.cc
src/ICAP/ICAPXaction.cc
src/SquidString.h
src/String.cc
src/String.cci
src/adaptation/Config.cc
src/client_side.cc
src/external_acl.cc
src/http.cc

index bbdbb08df095a86d0cd887385af564ed565066e2..54be55173d653d84c2b544e2c17b0d0c126b8a56 100644 (file)
@@ -79,7 +79,7 @@ int
 ACLExtUser::match(ACLChecklist *checklist)
 {
     if (checklist->request->extacl_user.size()) {
-        return data->match(checklist->request->extacl_user.unsafeBuf());
+        return data->match(checklist->request->extacl_user.termedBuf());
     } else {
         return -1;
     }
index fd31fc1a1786dbf142385dde754b826f08a74a47..1a2c801366fb00070bb144a8eb644f9de2b30d29 100644 (file)
@@ -87,10 +87,9 @@ AIODiskFile::open(int flags, mode_t mode, RefCount<IORequestor> callback)
 {
     /* Simulate async calls */
 #ifdef _SQUID_WIN32_
-    fd = aio_open(path.unsafeBuf(), flags);
+    fd = aio_open(path.termedBuf(), flags);
 #else
-
-    fd = file_open(path.unsafeBuf() , flags);
+    fd = file_open(path.termedBuf() , flags);
 #endif
 
     ioRequestor = callback;
index 8a5ce83816809be211a996f116e47cb2cf0e553b..b59880d009856888112bd6318753c8002c5d3e55 100644 (file)
@@ -109,7 +109,8 @@ ESICustomParser::parse(char const *dataToParse, size_t const lengthOfData, bool
     }
 
     size_t openESITags (0);
-    char const *currentPos = content.unsafeBuf();
+    //erring on the safe side. Probably rawBuf would be ok too
+    char const *currentPos = content.termedBuf();
     size_t remainingCount = content.size();
     char const *tag = NULL;
 
@@ -302,7 +303,7 @@ char const *
 ESICustomParser::errorString() const
 {
     if (error.size())
-        return error.unsafeBuf();
+        return error.termedBuf();
     else
         return "Parsing error strings not implemented";
 }
index 5bc39d8c2b326f765752534150337f2945282ca7..bd743c09960cb32b18dd65ae9657bef0154a478e 100644 (file)
@@ -279,7 +279,7 @@ void ICAPServiceRep::checkOptions()
         if (!method_found) {
             debugs(93,1, "WARNING: Squid is configured to use ICAP method " <<
                    cfg().methodStr() <<
-                   " for service " << cfg().uri.unsafeBuf() <<
+                   " for service " << cfg().uri <<
                    " but OPTIONS response declares the methods are " << method_list);
         }
     }
@@ -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.unsafeBuf());
+               " seconds: " << cfg().uri);
     }
 }
 
index 45dce4ceb3b941a4c850baeb885d154480554565..9bf529eddd236983ebfafef1d6730c2717bcc62a 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.unsafeBuf(), s.cfg().port, NULL, client_addr, isRetriable);
+    connection = icapPconnPool->pop(s.cfg().host.termedBuf(), 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.unsafeBuf());
+                           COMM_NONBLOCKING, s.cfg().uri.termedBuf());
 
     if (connection < 0)
         dieOnConnectionFailure(); // throws
 
-    debugs(93,3, typeName << " opens connection to " << s.cfg().host.unsafeBuf() << ":" << s.cfg().port);
+    debugs(93,3, typeName << " opens connection to " << s.cfg().host << ":" << 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.unsafeBuf(), s.cfg().port, connector);
+    commConnectStart(connection, s.cfg().host.termedBuf(), 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.unsafeBuf(),
+            icapPconnPool->push(connection, theService->cfg().host.termedBuf(),
                                 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.unsafeBuf() << status());
+           theService->cfg().uri << status());
     reuseConnection = false;
     service().noteFailure();
 
index a3ef838fd7d8910ac364377ccd5d606924d8725b..47e1194b2160e0c9842949b3a42a11c47c621f14 100644 (file)
@@ -88,6 +88,8 @@ public:
     String (String const &);
     ~String();
 
+    typedef unsigned int size_type; //storage size intentionally unspecified
+
     String &operator =(char const *);
     String &operator =(String const &);
     bool operator ==(String const &) const;
@@ -99,7 +101,7 @@ public:
      */
     _SQUID_INLINE_ char operator [](unsigned int pos) const;
 
-    _SQUID_INLINE_ size_t size() const;
+    _SQUID_INLINE_ size_type size() const;
     /// variant of size() suited to be used for printf-alikes.
     /// throws when size() > MAXINT
     _SQUID_INLINE_ int psize() const;
@@ -135,22 +137,22 @@ public:
     _SQUID_INLINE_ const char * pos(char const ch) const;
     ///offset from string start of the first occurrence of ch
     /// returns std::string::npos if ch is not found
-    _SQUID_INLINE_ size_t find(char const ch) const;
+    _SQUID_INLINE_ size_type find(char const ch) const;
     _SQUID_INLINE_ const char * rpos(char const ch) const;
-    _SQUID_INLINE_ size_t rfind(char const ch) const;
+    _SQUID_INLINE_ size_type rfind(char const ch) const;
     _SQUID_INLINE_ int cmp (char const *) const;
-    _SQUID_INLINE_ int cmp (char const *, size_t count) const;
+    _SQUID_INLINE_ int cmp (char const *, size_type count) const;
     _SQUID_INLINE_ int cmp (String const &) const;
     _SQUID_INLINE_ int caseCmp (char const *) const;
-    _SQUID_INLINE_ int caseCmp (char const *, size_t count) const;
+    _SQUID_INLINE_ int caseCmp (char const *, size_type count) const;
     _SQUID_INLINE_ int caseCmp (String const &) const;
 
-    String substr(size_t from, size_t to) const;
+    String substr(size_type from, size_type to) const;
 
     /** \deprecated Use assignment to [] position instead.
      *              ie   str[newLength] = '\0';
      */
-    _SQUID_INLINE_ void cut(size_t newLength);
+    _SQUID_INLINE_ void cut(size_type newLength);
 
 
 #if DEBUGSTRINGS
@@ -163,13 +165,13 @@ public:
 
 private:
     void allocAndFill(const char *str, int len);
-    void allocBuffer(size_t sz);
-    void setBuffer(char *buf, size_t sz);
+    void allocBuffer(size_type sz);
+    void setBuffer(char *buf, size_type sz);
 
     /* never reference these directly! */
-    size_t size_; /* buffer size; 64K limit */
+    size_type size_; /* buffer size; 64K limit */
 
-    size_t len_;  /* current length  */
+    size_type len_;  /* current length  */
 
     char *buf_;
 
index 1edb99111928a99933aa7ffc1495389d97865a92..bc129f14fab871466831d07fa75f8a639d01c876 100644 (file)
@@ -39,7 +39,7 @@
 // low-level buffer allocation,
 // does not free old buffer and does not adjust or look at len_
 void
-String::allocBuffer(size_t sz)
+String::allocBuffer(String::size_type sz)
 {
     PROF_start(StringInitBuf);
     assert (undefined());
@@ -51,7 +51,7 @@ String::allocBuffer(size_t sz)
 // low-level buffer assignment
 // does not free old buffer and does not adjust or look at len_
 void
-String::setBuffer(char *aBuf, size_t aSize)
+String::setBuffer(char *aBuf, String::size_type aSize)
 {
     assert(undefined());
     assert(aSize < 65536);
@@ -234,7 +234,7 @@ String::absorb(String &old)
 }
 
 String
-String::substr(size_t from, size_t to) const
+String::substr(String::size_type from, String::size_type to) const
 {
     Must(from >= 0 && from < size());
     Must(to > 0 && to <= size());
@@ -292,7 +292,7 @@ StringRegistry::remove
 
 StringRegistry StringRegistry::Instance_;
 
-extern size_t memStringCount();
+extern String::size_type memStringCount();
 
 void
 StringRegistry::Stat(StoreEntry *entry)
index a5fd17acd92f9ebad80be99a65d034e7565d9407..751086aa59381f3675cbf0c6cc28244596f5eb1a 100644 (file)
@@ -52,7 +52,7 @@ String::String() : size_(0), len_(0), buf_ (NULL)
 #endif
 }
 
-size_t
+String::size_type
 String::size() const
 {
     return len_;
@@ -113,7 +113,7 @@ String::pos(char const ch) const
     return strchr(termedBuf(), ch);
 }
 
-size_t
+String::size_type
 String::find(char const ch) const
 {
     const char *c;
@@ -129,7 +129,7 @@ String::rpos(char const ch) const
     return strrchr(termedBuf(), (ch));
 }
 
-size_t
+String::size_type
 String::rfind(char const ch) const
 {
     const char *c;
@@ -158,7 +158,7 @@ String::cmp (char const *aString) const
 }
 
 int
-String::cmp (char const *aString, size_t count) const
+String::cmp (char const *aString, String::size_type count) const
 {
     /* always the same at length 0 */
 
@@ -201,7 +201,7 @@ String::caseCmp(char const *aString) const
 }
 
 int
-String::caseCmp(char const *aString, size_t count) const
+String::caseCmp(char const *aString, String::size_type count) const
 {
     return strncasecmp(termedBuf(), aString, count);
 }
@@ -222,7 +222,7 @@ String::set(char const *loc, char const ch)
 }
 
 void
-String::cut(size_t newLength)
+String::cut(String::size_type newLength)
 {
     if (newLength < 0 || newLength > len_) return;
 
index ce1fb7c5055ace1a64fdbefc1efcb246419b57ce..ac5f17ee23382d1260fc8e38632750740ec42a88 100644 (file)
@@ -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.unsafeBuf());
+        storeAppendPrintf(entry, "%s %.*s\n", name, (*i)->id.psize(), (*i)->id.rawBuf());
 }
 
 void
@@ -181,7 +181,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.unsafeBuf());
+        snprintf(nom, 64, "%s %.*s", name, (*i)->groupId.psize(), (*i)->groupId.rawBuf());
         dump_acl_access(entry, nom, (*i)->acl);
     }
 }
index 021ecfd135f634a729fc3f9817c9d4714801d14f..98d2924712ff08365c2bc0f3b1104ac512604f14 100644 (file)
@@ -1168,8 +1168,9 @@ ClientSocketContext::buildRangeHeader(HttpReply * rep)
             /* delete old Content-Type, add ours */
             hdr->delById(HDR_CONTENT_TYPE);
             httpHeaderPutStrf(hdr, HDR_CONTENT_TYPE,
-                              "multipart/byteranges; boundary=\"%s\"",
-                              http->range_iter.boundary.unsafeBuf());
+                              "multipart/byteranges; boundary=\"%.*s\"",
+                              http->range_iter.boundary.psize(),
+                              http->range_iter.boundary.rawBuf());
             /* Content-Length is not required in multipart responses
              * but it is always nice to have one */
             actual_clen = http->mRangeCLen();
index 93b2534420bcf42dc596f4d8e912672b8f65a40d..7adc8f610bf9f23f1e8302d00a1a90c8d6a347cb 100644 (file)
@@ -753,7 +753,7 @@ aclMatchExternal(external_acl_data *acl, ACLChecklist * ch)
 
     external_acl_cache_touch(acl->def, entry);
     result = entry->result;
-    external_acl_message = entry->message.unsafeBuf();
+    external_acl_message = entry->message.termedBuf();
 
     debugs(82, 2, "aclMatchExternal: " << acl->def->name << " = " << result);
 
index 7a0a1a27ef76fd5b73d01dde76f24d18a57a5b65..af9caa2ab50f04c88512af0162a1780ee2f61a5d 100644 (file)
@@ -1808,7 +1808,7 @@ copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, co
          * pass on all other header fields
          * which are NOT listed by the special Connection: header. */
 
-        if (strConnection.size()>0 && strListIsMember(&strConnection, e->name.unsafeBuf(), ',')) {
+        if (strConnection.size()>0 && strListIsMember(&strConnection, e->name.termedBuf(), ',')) {
             debugs(11, 2, "'" << e->name << "' header cropped by Connection: definition");
             return;
         }