--------------------- PatchSet 11383 Date: 2007/04/24 21:28:50 Author: hno Branch: SQUID_2_6 Tag: (none) Log: Author: Mark Bergsma MFC: 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. Merged changes: 2007/04/17 12:01:57 Mark Bergsma +17 -6 Bug #1820: COSS assertion failure t->length == MD5_DIGEST_CHARS Members: src/fs/coss/store_dir_coss.c:1.66.2.1->1.66.2.2 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.66.2.1 retrieving revision 1.66.2.2 diff -u -r1.66.2.1 -r1.66.2.2 --- squid/src/fs/coss/store_dir_coss.c 3 Mar 2007 13:32:44 -0000 1.66.2.1 +++ squid/src/fs/coss/store_dir_coss.c 24 Apr 2007 21:28:50 -0000 1.66.2.2 @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.c,v 1.66.2.1 2007/03/03 13:32:44 hno Exp $ + * $Id: store_dir_coss.c,v 1.66.2.2 2007/04/24 21:28:50 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;