Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.2
squid
12711.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 12711.patch of Package squid
--------------------- PatchSet 12711 Date: 2011/08/26 21:51:44 Author: hno Branch: SQUID_2_7 Tag: (none) Log: Correct parsing of large gopher indexes Members: src/gopher.c:1.181.2.1->1.181.2.2 Index: squid/src/gopher.c =================================================================== RCS file: /cvsroot/squid/squid/src/gopher.c,v retrieving revision 1.181.2.1 retrieving revision 1.181.2.2 diff -u -r1.181.2.1 -r1.181.2.2 --- squid/src/gopher.c 4 May 2008 23:23:13 -0000 1.181.2.1 +++ squid/src/gopher.c 26 Aug 2011 21:51:44 -0000 1.181.2.2 @@ -1,6 +1,6 @@ /* - * $Id: gopher.c,v 1.181.2.1 2008/05/04 23:23:13 hno Exp $ + * $Id: gopher.c,v 1.181.2.2 2011/08/26 21:51:44 hno Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -314,8 +314,6 @@ gopherState->HTML_header_added = 1; return; } - inbuf[len] = '\0'; - if (!gopherState->HTML_header_added) { if (gopherState->conversion == HTML_CSO_RESULT) gopherHTMLHeader(entry, "CSO Search Result", NULL); @@ -325,66 +323,41 @@ gopherState->HTML_header_added = 1; gopherState->HTML_pre = 1; } - while ((pos != NULL) && (pos < inbuf + len)) { - + while (pos < inbuf + len) { + int llen; + int left = len - (pos - inbuf); + lpos = memchr(pos, '\n', left); + if (lpos) { + lpos++; /* Next line is after \n */ + llen = lpos - pos; + } else { + llen = left; + } + if (gopherState->len + llen >= TEMP_BUF_SIZE) { + debug(10, 1) ("gopherToHTML: Buffer overflow. Lost some data on URL: %s\n", + storeUrl(entry)); + llen = TEMP_BUF_SIZE - gopherState->len - 1; + } + if (!lpos) { + /* there is no complete line in inbuf */ + /* copy it to temp buffer */ + /* note: llen is adjusted above */ + xmemcpy(gopherState->buf + gopherState->len, pos, llen); + gopherState->len += llen; + break; + } if (gopherState->len != 0) { /* there is something left from last tx. */ - xstrncpy(line, gopherState->buf, gopherState->len + 1); - if (gopherState->len + len > TEMP_BUF_SIZE) { - debug(10, 1) ("gopherToHTML: Buffer overflow. Lost some data on URL: %s\n", - storeUrl(entry)); - len = TEMP_BUF_SIZE - gopherState->len; - } - lpos = (char *) memccpy(line + gopherState->len, inbuf, '\n', len); - if (lpos) - *lpos = '\0'; - else { - /* there is no complete line in inbuf */ - /* copy it to temp buffer */ - if (gopherState->len + len > TEMP_BUF_SIZE) { - debug(10, 1) ("gopherToHTML: Buffer overflow. Lost some data on URL: %s\n", - storeUrl(entry)); - len = TEMP_BUF_SIZE - gopherState->len; - } - xmemcpy(gopherState->buf + gopherState->len, inbuf, len); - gopherState->len += len; - return; - } - - /* skip one line */ - pos = (char *) memchr(pos, '\n', len); - if (pos) - pos++; - - /* we're done with the remain from last tx. */ + xmemcpy(line, gopherState->buf, gopherState->len); + xmemcpy(line + gopherState->len, pos, llen); + llen += gopherState->len; gopherState->len = 0; - *(gopherState->buf) = '\0'; } else { - - lpos = (char *) memccpy(line, pos, '\n', len - (pos - inbuf)); - if (lpos) - *lpos = '\0'; - else { - /* there is no complete line in inbuf */ - /* copy it to temp buffer */ - if ((len - (pos - inbuf)) > TEMP_BUF_SIZE) { - debug(10, 1) ("gopherToHTML: Buffer overflow. Lost some data on URL: %s\n", - storeUrl(entry)); - len = TEMP_BUF_SIZE; - } - if (len > (pos - inbuf)) { - xmemcpy(gopherState->buf, pos, len - (pos - inbuf)); - gopherState->len = len - (pos - inbuf); - } - break; - } - - /* skip one line */ - pos = (char *) memchr(pos, '\n', len); - if (pos) - pos++; - + xmemcpy(line, pos, llen); } + line[llen + 1] = '\0'; + /* move input to next line */ + pos = lpos; /* at this point. We should have one line in buffer to process */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor