From: Francesco Chemolli Date: Fri, 6 Feb 2009 00:59:06 +0000 (+0100) Subject: more String fixups X-Git-Tag: SQUID_3_2_0_1~1189^2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17bc3f221d0ebd9d8139f849e347da724705b865;p=thirdparty%2Fsquid.git more String fixups --- diff --git a/src/ESISegment.cc b/src/ESISegment.cc index 9ecd388384..d82e5185e5 100644 --- a/src/ESISegment.cc +++ b/src/ESISegment.cc @@ -236,5 +236,5 @@ ESISegment::dumpOne() const { String temp; temp.limitInit(buf, len); - debugs(86, 9, "ESISegment::dumpOne: \"" << temp.unsafeBuf() << "\""); + debugs(86, 9, "ESISegment::dumpOne: \"" << temp << "\""); } diff --git a/src/access_log.cc b/src/access_log.cc index 4e95bd8fd9..9f7c1f2f37 100644 --- a/src/access_log.cc +++ b/src/access_log.cc @@ -625,7 +625,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) if (al->request) sb = al->request->header.getByName(fmt->data.header.header); - out = sb.unsafeBuf(); + out = sb.termedBuf(); 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.unsafeBuf(); + out = sb.termedBuf(); 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.unsafeBuf(); + out = sb.termedBuf(); 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.unsafeBuf(); + out = sb.termedBuf(); quote = 1; @@ -764,7 +764,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) case LFT_REQUEST_URLPATH: if (al->request) { - out = al->request->urlpath.unsafeBuf(); + out = al->request->urlpath.termedBuf(); quote = 1; } break; @@ -810,7 +810,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) case LFT_TAG: if (al->request) - out = al->request->tag.unsafeBuf(); + out = al->request->tag.termedBuf(); quote = 1; @@ -823,7 +823,7 @@ accessLogCustom(AccessLogEntry * al, customlog * log) case LFT_EXT_LOG: if (al->request) - out = al->request->extacl_log.unsafeBuf(); + out = al->request->extacl_log.termedBuf(); quote = 1; diff --git a/src/urn.cc b/src/urn.cc index b180aca99e..f20f3f9b57 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -57,7 +57,7 @@ public: char *getHost (String &urlpath); void setUriResFromRequest(HttpRequest *); bool RequestNeedsMenu(HttpRequest *r); - void updateRequestURL(HttpRequest *r, char const *newPath); + void updateRequestURL(HttpRequest *r, char const *newPath, const size_t newPath_len); void createUriResRequest (String &uri); virtual ~UrnState(); @@ -182,13 +182,16 @@ UrnState::getHost (String &urlpath) bool UrnState::RequestNeedsMenu(HttpRequest *r) { - return strncasecmp(r->urlpath.unsafeBuf(), "menu.", 5) == 0; + if (r->urlpath.size() < 5) + return false; + //now we're sure it's long enough + return strncasecmp(r->urlpath.rawBuf(), "menu.", 5) == 0; } void -UrnState::updateRequestURL(HttpRequest *r, char const *newPath) +UrnState::updateRequestURL(HttpRequest *r, char const *newPath, const size_t newPath_len) { - char *new_path = xstrdup (newPath); + char *new_path = xstrndup (newPath, newPath_len); r->urlpath = new_path; xfree(new_path); } @@ -198,7 +201,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.unsafeBuf()); + snprintf(local_urlres, 4096, "http://%s/uri-res/N2L?urn:%.*s", host, uri.size(), uri.rawBuf()); safe_free (host); safe_free (urlres); urlres = xstrdup (local_urlres); @@ -209,7 +212,7 @@ void UrnState::setUriResFromRequest(HttpRequest *r) { if (RequestNeedsMenu(r)) { - updateRequestURL(r, r->urlpath.unsafeBuf() + 5); + updateRequestURL(r, r->urlpath.rawBuf() + 5, r->urlpath.size() - 5 ); flags.force_menu = 1; } diff --git a/src/whois.cc b/src/whois.cc index 3eb3cfc3b3..7818b8e9bb 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -98,7 +98,7 @@ whoisStart(FwdState * fwd) buf = (char *)xmalloc(l); - snprintf(buf, l, "%s\r\n", p->request->urlpath.unsafeBuf() + 1); + snprintf(buf, l, "%.*s\r\n", p->request->urlpath.size()-1, p->request->urlpath.rawBuf() + 1); comm_write(fd, buf, strlen(buf), whoisWriteComplete, p, NULL); comm_read(fd, p->buf, BUFSIZ, whoisReadReply, p);