]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Verified and converted more String users.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 31 Jan 2009 16:40:06 +0000 (17:40 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 31 Jan 2009 16:40:06 +0000 (17:40 +0100)
src/ftp.cc
src/gopher.cc
src/http.cc

index 56758436f71a186f041a8a818c88939fb7e4f9b2..23093e66767ecd98bb97ca5bd8a1d61e3b6d5e30 100644 (file)
@@ -1574,7 +1574,7 @@ FtpStateData::start()
     checkUrlpath();
     buildTitleUrl();
     debugs(9, 5, HERE << "host=" << request->GetHost() << ", path=" <<
-           request->urlpath.unsafeBuf() << ", user=" << user << ", passwd=" <<
+           request->urlpath << ", 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.unsafeBuf();
+            filename = t ? t + 1 : ftpState->request->urlpath.termedBuf();
             mode = mimeGetTransferMode(filename);
         }
 
@@ -2054,7 +2054,7 @@ ftpReadType(FtpStateData * ftpState)
     debugs(9, 3, HERE);
 
     if (code == 200) {
-        p = path = xstrdup(ftpState->request->urlpath.unsafeBuf());
+        p = path = xstrdup(ftpState->request->urlpath.termedBuf());
 
         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.unsafeBuf());
+                   ftpState->title_url);
             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.unsafeBuf());
+    path = xstrdup(ftpState->request->urlpath.termedBuf());
 
     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.unsafeBuf();
+    filename = (t = urlpath.rpos('/')) ? t + 1 : urlpath.termedBuf();
 
     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.unsafeBuf(), "/", 1) ) {
+    if ( request->urlpath[0]=='/' ) {
         newbuf.append(request->urlpath);
         request->urlpath.absorb(newbuf);
         safe_free(request->canonical);
-    } else if ( !strncmp(request->urlpath.unsafeBuf(), "%2f", 3) ) {
-        newbuf.append(request->urlpath.unsafeBuf() +1);
+    } else if ( !strncmp(request->urlpath.termedBuf(), "%2f", 3) ) {
+        newbuf.append(request->urlpath.rawBuf() +1, request->urlpath.size()-1);
         request->urlpath.absorb(newbuf);
         safe_free(request->canonical);
     }
index bc6ae886885ae7b745d3f05be38dedf280a70876..6d86a34d8c8d1632ac1c0a07438bec36451c5c13 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.unsafeBuf();
+    const char *path = req->urlpath.termedBuf();
 
     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.unsafeBuf(), outbuf.size());
+        entry->append(outbuf.rawBuf(), outbuf.size());
         /* now let start sending stuff to client */
         entry->flush();
     }
index 87bd35a95a07d82f862ba3fa411b95a0f3b3c736..77259157bf744560dacf675a3ab77ec4c0f4c31b 100644 (file)
@@ -93,7 +93,7 @@ HttpStateData::HttpStateData(FwdState *theFwdState) : AsyncJob("HttpStateData"),
         const char *url;
 
         if (_peer->options.originserver)
-            url = orig_request->urlpath.unsafeBuf();
+            url = orig_request->urlpath.termedBuf();
         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.unsafeBuf();
+        value = hdr.termedBuf();
 
         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.unsafeBuf();
+        value = hdr.termedBuf();
 
         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.unsafeBuf());
-    return vstr.unsafeBuf();
+    debugs(11, 3, "httpMakeVaryMark: " << vstr);
+    return vstr.termedBuf();
 }
 
 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.unsafeBuf(), "Session-Based-Authentication") != NULL);
+    rc = (strstr(header.termedBuf(), "Session-Based-Authentication") != NULL);
 
     return rc;
 }
@@ -988,11 +988,11 @@ HttpStateData::persistentConnStatus() const
  */
 /*
 void
-HttpStateData::ReadReplyWrapper(int fd, char *unsafeBuf, size_t len, comm_err_t flag, int xerrno, void *data)
+HttpStateData::ReadReplyWrapper(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *data)
 {
     HttpStateData *httpState = static_cast<HttpStateData *>(data);
     assert (fd == httpState->fd);
-    // assert(unsafeBuf == readBuf->content());
+    // assert(buf == 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(*unsafeBuf))
-            xmemmove(unsafeBuf, unsafeBuf + 1, len--);
+        while (len > 0 && xisspace(*buf))
+            xmemmove(buf, buf + 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.unsafeBuf());
+        hdr_out->putStr(HDR_VIA, strVia.termedBuf());
         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.unsafeBuf());
+        hdr_out->putStr(HDR_SURROGATE_CAPABILITY, strSurrogate.termedBuf());
     }
 #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.unsafeBuf());
+            hdr_out->putStr(HDR_X_FORWARDED_FOR, strFwd.termedBuf());
     }
     /** 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.unsafeBuf();
+                username = orig_request->extacl_user.termedBuf();
             else if (orig_request->auth_user_request)
                 username = orig_request->auth_user_request->username();
 
@@ -1542,7 +1542,11 @@ 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.unsafeBuf(), orig_request->extacl_passwd.unsafeBuf());
+                snprintf(loginbuf, sizeof(loginbuf), "%.*s:%.*s",
+                    orig_request->extacl_user.size(),
+                    orig_request->extacl_user.rawBuf(),
+                    orig_request->extacl_passwd.size(),
+                    orig_request->extacl_passwd.rawBuf());
                 httpHeaderPutStrf(hdr_out, HDR_PROXY_AUTHORIZATION, "Basic %s",
                                   base64_encode(loginbuf));
             }
@@ -1569,7 +1573,11 @@ 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.unsafeBuf(), orig_request->extacl_passwd.unsafeBuf());
+                snprintf(loginbuf, sizeof(loginbuf), "%.*s:%.*s",
+                    orig_request->extacl_user.size(),
+                    orig_request->extacl_user.rawBuf(),
+                    orig_request->extacl_passwd.size(),
+                    orig_request->extacl_passwd.rawBuf());
                 httpHeaderPutStrf(hdr_out, HDR_AUTHORIZATION, "Basic %s",
                                   base64_encode(loginbuf));
             }