Patch for previously-reported problem fetching gopher data

From: WWW server manager <>
Date: Fri, 3 Oct 1997 22:59:35 +0100 (BST)

A couple of weeks ago, I reported a problem with gopher data being
passed to clients in corrupted form (sometimes with garbled data, most often
with groups of lines missing) when displaying some of our gopher menus. The
problem could be seen, for example, with URL
gopher:// if you want
to try checking before-and-after appearance (but note that what you get will
change on a daily basis, anyway).

I've now tracked down the problem, and enclose a patch (based on Squid
1.NOVM.16's gopher.c) for it. Comments welcome on whether I've got the fix

The cause of the problem was long gopher menu lines (long descriptions and
long filenames derived from the descriptions) over 256 bytes long.

The gopherToHTML function is called repeatedly for blocks of data as they
are received from the gopher server; it allows for the possibility of a
partial line carried forward from the previous block, and steps through and
formats the complete lines in the current block (though with the URL
above, it looks you you get blocks of complete lines, around 1.5K bytes).

The problem is that while it scans the whole of the text remaining in the
current block when copying the current line, it subsequently scans only the
first 256 bytes when updating the input data pointer to skip that line,
getting NULL if the line is longer and causing it to "forget" the remaining
data in the current block, seen as missing groups of menu entries in the
cases that brought it to my attention.

My fix simply uses the actual amount of residual data in place of the
two hard-wired uses of 256, assuming I've not missed any subtleties.

                                John Line

===== gopher.c patch (against Squid 1.NOVM.16)
*** gopher.c.original Thu Oct 2 15:06:24 1997
--- gopher.c Thu Oct 2 15:09:31 1997
*** 1,3 ****
--- 1,4 ----
+ /* Modified JML 2 Oct 1997: do not lose data due to long input lines */
   * $Id: gopher.c,v 1997/06/20 16:48:27 wessels Exp $
*** 461,467 ****
              /* skip one line */
! pos = (char *) memchr(pos, '\n', 256);
              if (pos)
--- 462,468 ----
              /* skip one line */
! pos = (char *) memchr(pos, '\n', len);
              if (pos)
*** 489,495 ****
              /* skip one line */
! pos = (char *) memchr(pos, '\n', 256);
              if (pos)
--- 490,496 ----
              /* skip one line */
! pos = (char *) memchr(pos, '\n', len - (pos - inbuf));
              if (pos)

University of Cambridge WWW manager account (usually John Line)
Send general WWW-related enquiries to
Received on Fri Oct 03 1997 - 15:04:20 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:37:15 MST