--------------------- PatchSet 3693 Date: 2002/02/23 21:41:03 Author: serassio Branch: nt-2_3 Tag: (none) Log: Backported from 2.4 Fix of problem with certain non-anonymous & an old HTCP bug fix from HEAD Members: doc/WIN32-ChangeLog.txt:1.1.2.9->1.1.2.10 src/fd.c:1.1.1.3.4.1.2.5->1.1.1.3.4.1.2.6 src/ftp.c:1.1.1.3.4.3.2.6->1.1.1.3.4.3.2.7 src/htcp.c:1.1.1.2.4.1.2.6->1.1.1.2.4.1.2.7 src/protos.h:1.1.1.3.4.1.2.11->1.1.1.3.4.1.2.12 src/tools.c:1.1.1.3.4.1.2.15->1.1.1.3.4.1.2.16 Index: squid/doc/WIN32-ChangeLog.txt =================================================================== RCS file: /cvsroot/squid-sf//squid/doc/Attic/WIN32-ChangeLog.txt,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- squid/doc/WIN32-ChangeLog.txt 17 Feb 2002 08:57:57 -0000 1.1.2.9 +++ squid/doc/WIN32-ChangeLog.txt 23 Feb 2002 21:41:03 -0000 1.1.2.10 @@ -64,4 +64,7 @@ 16 Feb 2002 - Backported SNMP patches from HEAD - (Guido Serassio) 17 Feb 2002 - Added "Reconfigure the Squid Process" functionality to Cache Manager - (Guido Serassio) - Added WIN32 specific info in "General Runtime Information" Cache Manager - function - (Guido Serassio) \ No newline at end of file + function - (Guido Serassio) +23 Feb 2002 - Backported from 2.4 of Fix of problem with certain non-anonymous + ftp:// style URL's - (Guido Serassio) + - Backported an old HTCP bug fix from HEAD - (Guido Serassio) \ No newline at end of file Index: squid/src/fd.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fd.c,v retrieving revision 1.1.1.3.4.1.2.5 retrieving revision 1.1.1.3.4.1.2.6 diff -u -r1.1.1.3.4.1.2.5 -r1.1.1.3.4.1.2.6 --- squid/src/fd.c 3 Feb 2002 15:15:35 -0000 1.1.1.3.4.1.2.5 +++ squid/src/fd.c 23 Feb 2002 21:41:03 -0000 1.1.1.3.4.1.2.6 @@ -1,6 +1,6 @@ /* - * $Id: fd.c,v 1.1.1.3.4.1.2.5 2002/02/03 15:15:35 serassio Exp $ + * $Id: fd.c,v 1.1.1.3.4.1.2.6 2002/02/23 21:41:03 serassio Exp $ * * DEBUG: section 51 Filedescriptor Functions * AUTHOR: Duane Wessels @@ -93,8 +93,9 @@ void sd_open(int fd, unsigned int type, const char *desc) { - sde *F = &sd_table[fd]; + sde *F; assert(fd >= 0); + F = &sd_table[fd]; #if USE_ASYNC_IO if (F->flags.closing) { /* Reuse of a closed FD before we have noticed it is closed */ Index: squid/src/ftp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ftp.c,v retrieving revision 1.1.1.3.4.3.2.6 retrieving revision 1.1.1.3.4.3.2.7 diff -u -r1.1.1.3.4.3.2.6 -r1.1.1.3.4.3.2.7 --- squid/src/ftp.c 27 Jan 2002 18:38:40 -0000 1.1.1.3.4.3.2.6 +++ squid/src/ftp.c 23 Feb 2002 21:41:03 -0000 1.1.1.3.4.3.2.7 @@ -1,6 +1,6 @@ /* - * $Id: ftp.c,v 1.1.1.3.4.3.2.6 2002/01/27 18:38:40 serassio Exp $ + * $Id: ftp.c,v 1.1.1.3.4.3.2.7 2002/02/23 21:41:03 serassio Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -89,8 +89,8 @@ int password_url; char *reply_hdr; int reply_hdr_state; - char *title_url; - char *base_href; + String title_url; + String base_href; int conn_att; int login_att; ftp_state_t state; @@ -299,8 +299,8 @@ safe_free(ftpState->old_request); safe_free(ftpState->old_reply); safe_free(ftpState->old_filepath); - safe_free(ftpState->title_url); - safe_free(ftpState->base_href); + stringClean(&ftpState->title_url); + stringClean(&ftpState->base_href); safe_free(ftpState->filepath); safe_free(ftpState->data.host); if (ftpState->data.fd > -1) { @@ -362,11 +362,11 @@ storeAppendPrintf(e, "\n", mkrfc1123(squid_curtime)); storeAppendPrintf(e, "
\n"); @@ -379,8 +379,8 @@ storeAppendPrintf(e, "\n"); storeAppendPrintf(e, "FTP Directory: "); /* "ftp://" == 6 characters */ - assert(strlen(ftpState->title_url) >= 6); - title = html_quote(ftpState->title_url); + assert(strLen(ftpState->title_url) >= 6); + title = html_quote(strBuf(ftpState->title_url)); for (i = 6, j = 0; title[i]; j = i) { storeAppendPrintf(e, ""); for (k = j; k < i - 1; k++) storeAppendPrintf(e, "%c", title[k]); - if (ftpState->title_url[k] != '/') + if (strBuf(ftpState->title_url)[k] != '/') storeAppendPrintf(e, "%c", title[k++]); storeAppendPrintf(e, ""); if (k < i) @@ -399,8 +399,8 @@ if (i == j) { /* Error guard, or "assert" */ storeAppendPrintf(e, "ERROR: Failed to parse URL: %s\n", - html_quote(ftpState->title_url)); - debug(9, 0) ("Failed to parse URL: %s\n", ftpState->title_url); + html_quote(strBuf(ftpState->title_url))); + debug(9, 0) ("Failed to parse URL: %s\n", strBuf(ftpState->title_url)); break; } } @@ -1004,38 +1004,35 @@ ftpBuildTitleUrl(FtpStateData * ftpState) { request_t *request = ftpState->request; - size_t len; - char *t; - len = 64 - + strlen(ftpState->user) - + strlen(ftpState->password) - + strlen(request->host) - + strLen(request->urlpath); - t = ftpState->title_url = xcalloc(len, 1); - strcat(t, "ftp://"); + + stringReset(&ftpState->title_url, "ftp://"); if (strcmp(ftpState->user, "anonymous")) { - strcat(t, ftpState->user); - strcat(t, "@"); + strCat(ftpState->title_url, ftpState->user); + strCat(ftpState->title_url, "@"); + } + strCat(ftpState->title_url, request->host); + if (request->port != urlDefaultPort(PROTO_FTP)) { + strCat(ftpState->title_url, ":"); + strCat(ftpState->title_url, xitoa(request->port)); } - strcat(t, request->host); - if (request->port != urlDefaultPort(PROTO_FTP)) - snprintf(&t[strlen(t)], len - strlen(t), ":%d", request->port); - strcat(t, strBuf(request->urlpath)); - t = ftpState->base_href = xcalloc(len, 1); - strcat(t, "ftp://"); + strCat(ftpState->title_url, strBuf(request->urlpath)); + + stringReset(&ftpState->base_href, "ftp://"); if (strcmp(ftpState->user, "anonymous")) { - strcat(t, rfc1738_escape_part(ftpState->user)); + strCat(ftpState->base_href, rfc1738_escape_part(ftpState->user)); if (ftpState->password_url) { - strcat(t, ":"); - strcat(t, rfc1738_escape_part(ftpState->password)); + strCat(ftpState->base_href, ":"); + strCat(ftpState->base_href, rfc1738_escape_part(ftpState->password)); } - strcat(t, "@"); + strCat(ftpState->base_href, "@"); + } + strCat(ftpState->base_href, request->host); + if (request->port != urlDefaultPort(PROTO_FTP)) { + strCat(ftpState->base_href, ":"); + strCat(ftpState->base_href, xitoa(request->port)); } - strcat(t, request->host); - if (request->port != urlDefaultPort(PROTO_FTP)) - snprintf(&t[strlen(t)], len - strlen(t), ":%d", request->port); - strcat(t, strBuf(request->urlpath)); - strcat(t, "/"); + strCat(ftpState->base_href, strBuf(request->urlpath)); + strCat(ftpState->base_href, "/"); } void @@ -1593,7 +1590,7 @@ { if (!ftpState->flags.isdir) { debug(9, 3) ("Directory path did not end in /\n"); - strcat(ftpState->title_url, "/"); + strCat(ftpState->title_url, "/"); ftpState->flags.isdir = 1; ftpState->flags.use_base = 1; } @@ -1650,7 +1647,7 @@ if (ftpState->size == 0) { debug(9, 2) ("ftpReadSize: SIZE reported %s on %s\n", ftpState->ctrl.last_reply, - ftpState->title_url); + strBuf(ftpState->title_url)); ftpState->size = -1; } } else if (code < 0) { Index: squid/src/htcp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/htcp.c,v retrieving revision 1.1.1.2.4.1.2.6 retrieving revision 1.1.1.2.4.1.2.7 diff -u -r1.1.1.2.4.1.2.6 -r1.1.1.2.4.1.2.7 --- squid/src/htcp.c 27 Jan 2002 18:38:41 -0000 1.1.1.2.4.1.2.6 +++ squid/src/htcp.c 23 Feb 2002 21:41:03 -0000 1.1.1.2.4.1.2.7 @@ -1,6 +1,6 @@ /* - * $Id: htcp.c,v 1.1.1.2.4.1.2.6 2002/01/27 18:38:41 serassio Exp $ + * $Id: htcp.c,v 1.1.1.2.4.1.2.7 2002/02/23 21:41:03 serassio Exp $ * * DEBUG: section 31 Hypertext Caching Protocol * AUTHOR: Duane Wesssels @@ -748,8 +748,9 @@ hdr.msg_id = ntohl(hdr.msg_id); debug(31, 3) ("htcpHandleData: sz = %d\n", sz); debug(31, 3) ("htcpHandleData: length = %d\n", (int) hdr.length); - if (hdr.opcode > HTCP_END) { - debug(31, 0) ("htcpHandleData: opcode %d out of range\n", + if (hdr.opcode >= HTCP_END) { + debug(31, 0) ("htcpHandleData: client %s, opcode %d out of range\n", + inet_ntoa(from->sin_addr), (int) hdr.opcode); return; } @@ -785,6 +786,10 @@ case HTCP_SET: htcpHandleSet(&hdr, buf, sz, from); break; + case HTCP_CLR: + debug(31, 1) ("htcpHandleData: client %s, CLR not supported\n", + inet_ntoa(from->sin_addr)); + break; default: assert(0); break; @@ -898,10 +903,8 @@ Packer pa; MemBuf mb; http_state_flags flags; - if (htcpInSocket < 0) return; - memset(&flags, '\0', sizeof(flags)); snprintf(vbuf, sizeof(vbuf), "%3.1f", req->http_ver); stuff.op = HTCP_TST; Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.1.1.3.4.1.2.11 retrieving revision 1.1.1.3.4.1.2.12 diff -u -r1.1.1.3.4.1.2.11 -r1.1.1.3.4.1.2.12 --- squid/src/protos.h 10 Feb 2002 17:55:57 -0000 1.1.1.3.4.1.2.11 +++ squid/src/protos.h 23 Feb 2002 21:41:03 -0000 1.1.1.3.4.1.2.12 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.1.1.3.4.1.2.11 2002/02/10 17:55:57 serassio Exp $ + * $Id: protos.h,v 1.1.1.3.4.1.2.12 2002/02/23 21:41:03 serassio Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -1134,7 +1134,7 @@ #define strSet(s,ptr,ch) (s).buf[ptr-(s).buf] = (ch) #define strCut(s,pos) (((s).len = pos) , ((s).buf[pos] = '\0')) #define strCutPtr(s,ptr) (((s).len = (ptr)-(s).buf) , ((s).buf[(s).len] = '\0')) -/* #define strCat(s,str) stringAppend(&(s), (str), strlen(str)+1) */ +#define strCat(s,str) stringAppend(&(s), (str), strlen(str)) extern void stringInit(String * s, const char *str); extern void stringLimitInit(String * s, const char *str, int len); extern String stringDup(const String * s); Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/tools.c,v retrieving revision 1.1.1.3.4.1.2.15 retrieving revision 1.1.1.3.4.1.2.16 diff -u -r1.1.1.3.4.1.2.15 -r1.1.1.3.4.1.2.16 --- squid/src/tools.c 10 Feb 2002 17:55:57 -0000 1.1.1.3.4.1.2.15 +++ squid/src/tools.c 23 Feb 2002 21:41:03 -0000 1.1.1.3.4.1.2.16 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.1.1.3.4.1.2.15 2002/02/10 17:55:57 serassio Exp $ + * $Id: tools.c,v 1.1.1.3.4.1.2.16 2002/02/23 21:41:03 serassio Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -175,7 +175,7 @@ squid_getrusage(struct rusage *r) { memset(r, '\0', sizeof(struct rusage)); -#if (HAVE_GETRUSAGE && defined(RUSAGE_SELF)) +#if HAVE_GETRUSAGE && defined(RUSAGE_SELF) #ifdef _SQUID_SOLARIS_ /* Solaris 2.5 has getrusage() permission bug -- Arjan de Vet */ enter_suid();