--------------------- PatchSet 11380 Date: 2007/04/17 12:01:57 Author: hno Branch: HEAD Tag: (none) Log: Author: Mark Bergsma Bug #1820: COSS assertion failure t->length == MD5_DIGEST_CHARS This patch changes modifies some of the COSS rebuild code to not assert on certain corrupt objects, but instead log an error and ignore the object. Crashes are especially unhelpful because Squid will restart and keep crashing in a loop, until manual intervention in the form of a cache clear is done. Members: src/fs/coss/store_dir_coss.c:1.68->1.69 Index: squid/src/fs/coss/store_dir_coss.c =================================================================== RCS file: /cvsroot/squid/squid/src/fs/coss/store_dir_coss.c,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- squid/src/fs/coss/store_dir_coss.c 27 Feb 2007 09:01:53 -0000 1.68 +++ squid/src/fs/coss/store_dir_coss.c 17 Apr 2007 12:01:57 -0000 1.69 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.c,v 1.68 2007/02/27 09:01:53 serassio Exp $ + * $Id: store_dir_coss.c,v 1.69 2007/04/17 12:01:57 hno Exp $ * * DEBUG: section 47 Store COSS Directory Routines * AUTHOR: Eric Stern @@ -1299,22 +1299,33 @@ debug(47, 3) ("Size: %" PRINTF_OFF_T " (len %d)\n", *l, t->length); break; case STORE_META_KEY: - assert(t->length == MD5_DIGEST_CHARS); + if (t->length != MD5_DIGEST_CHARS) { + debug(47, 1) ("COSS: %s: stripe %d: offset %d has invalid STORE_META_KEY length. Ignoring object.\n", stripePath(SD), cs->rebuild.curstripe, j); + goto nextobject; + } xmemcpy(key, t->value, MD5_DIGEST_CHARS); break; #if SIZEOF_SQUID_FILE_SZ == SIZEOF_SIZE_T case STORE_META_STD: - assert(t->length == STORE_HDR_METASIZE); + if (t->length != STORE_HDR_METASIZE) { + debug(47, 1) ("COSS: %s: stripe %d: offset %d has invalid STORE_META_STD length. Ignoring object.\n", stripePath(SD), cs->rebuild.curstripe, j); + goto nextobject; + } xmemcpy(&tmpe.timestamp, t->value, STORE_HDR_METASIZE); break; #else case STORE_META_STD_LFS: - assert(t->length == STORE_HDR_METASIZE); + if (t->length != STORE_HDR_METASIZE) { + debug(47, 1) ("COSS: %s: stripe %d: offset %d has invalid STORE_META_STD_LFS length. Ignoring object.\n", stripePath(SD), cs->rebuild.curstripe, j); + goto nextobject; + } xmemcpy(&tmpe.timestamp, t->value, STORE_HDR_METASIZE); break; case STORE_META_STD: - assert(t->length == STORE_HDR_METASIZE_OLD); - { + if (t->length != STORE_HDR_METASIZE_OLD) { + debug(47, 1) ("COSS: %s: stripe %d: offset %d has invalid STORE_META_STD length. Ignoring object.\n", stripePath(SD), cs->rebuild.curstripe, j); + goto nextobject; + } { struct { time_t timestamp; time_t lastref;