--------------------- PatchSet 10271 Date: 2007/12/17 16:40:05 Author: adri Branch: s27_adri Tag: (none) Log: Fix the busted stringAppend() code, argh! Its ugly and it could trigger an assert if a string is -just- filled before NUL termination but leave a note to myself to come back and repair this mess at a later date. Members: ADRIAN_TODO:1.1.2.11->1.1.2.12 libbuf/String.c:1.1.2.11->1.1.2.12 Index: squid/ADRIAN_TODO =================================================================== RCS file: /cvsroot/squid-sf//squid/Attic/ADRIAN_TODO,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -u -r1.1.2.11 -r1.1.2.12 --- squid/ADRIAN_TODO 16 Dec 2007 16:14:22 -0000 1.1.2.11 +++ squid/ADRIAN_TODO 17 Dec 2007 16:40:05 -0000 1.1.2.12 @@ -66,3 +66,13 @@ * unit check start time - move strwordtok() out of src and into libcore; write a unit check for strwordtok() +* FTP URLs are busted (and that whole codepath is busted!) - try going to + ftp://ftp.iinet.net.au/pub/linux/debian + +* I think the append/concatenate might be off-by-one; the FTP title URL isn't + being built right. Write a test or two! + +* libbuf/String.c + /* XXX this is WRONG - we should be making sure there's space for the trailing \0 */ + /* XXX make absolutely sure this code is fixed to be valid (add flag to buf_append to NUL term or not) ! */ + Index: squid/libbuf/String.c =================================================================== RCS file: /cvsroot/squid-sf//squid/libbuf/Attic/String.c,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -u -r1.1.2.11 -r1.1.2.12 --- squid/libbuf/String.c 17 Dec 2007 08:14:03 -0000 1.1.2.11 +++ squid/libbuf/String.c 17 Dec 2007 16:40:06 -0000 1.1.2.12 @@ -1,6 +1,6 @@ /* - * $Id: String.c,v 1.1.2.11 2007/12/17 08:14:03 adri Exp $ + * $Id: String.c,v 1.1.2.12 2007/12/17 16:40:06 adri Exp $ * * DEBUG: section 67 String * AUTHOR: Duane Wessels @@ -128,6 +128,7 @@ void stringAppend(String * s, const char *str, int len) { + int a; assert(s); assert(str && len >= 0); @@ -138,12 +139,13 @@ stringMakePrivate(s); - /* The buffer will have a \0 at the end; so make sure we're not on it */ - /* XXX breaks layering again! */ - if (buf_len(s->nb) > 0) - buf_len(s->nb)--; + /* XXX this is WRONG - we should be making sure there's space for the trailing \0 */ + /* XXX make absolutely sure this code is fixed to be valid (add flag to buf_append to NUL term or not) ! */ + buf_append(s->nb, str, len); s->len += len; + a = buf_put_chr(s->nb, s->len, '\0'); + assert(a); } void