diff -u -r -x *.o -x *.orig -X exclude_files squid-1.0.alpha5/src/stmem.c squid-1.0.alpha5.henrik/src/stmem.c --- squid-1.0.alpha5/src/stmem.c Fri Mar 29 22:19:26 1996 +++ squid-1.0.alpha5.henrik/src/stmem.c Thu Apr 4 20:18:24 1996 @@ -175,12 +175,12 @@ str_i = string; } + i++; + blk_idx++; + /* Return offset of byte beyond the matching string */ if (state == goal) return (i + 1); - - i++; - blk_idx++; if (blk_idx >= p->len) { if (p->next) { diff -u -r -x *.o -x *.orig -X exclude_files squid-1.0.alpha5/src/store.c squid-1.0.alpha5.henrik/src/store.c --- squid-1.0.alpha5/src/store.c Tue Apr 2 02:51:55 1996 +++ squid-1.0.alpha5.henrik/src/store.c Thu Apr 4 20:01:01 1996 @@ -100,6 +100,7 @@ } static StoreEntry *new_StoreEntry(mem_obj_flag) + int mem_obj_flag; { StoreEntry *e = NULL; @@ -1380,7 +1381,7 @@ { debug(20, 5, "storeComplete: \n", e->url); - if (!e->key || e->flag & KEY_CHANGE) { + if (!e->key || e->flag & KEY_CHANGE || e->expires <= cached_curtime) { /* Never cache private objects */ BIT_SET(e->flag, RELEASE_REQUEST); BIT_RESET(e->flag, CACHABLE); @@ -1394,7 +1395,8 @@ /* start writing it to disk */ if ((e->flag & CACHABLE) && !(e->flag & RELEASE_REQUEST) && - (e->type_id == REQ_GET)) { + (e->type_id == REQ_GET) && + storeEntryValidLength(e)) { storeSwapOutStart(e); } /* free up incoming MIME */ @@ -2335,6 +2337,40 @@ if (e->expires == 0 && e->status == STORE_PENDING) return 1; return 0; +} + +int storeEntryValidLength(e) + StoreEntry *e; +{ + int headerlength,length; + char buf[1024]; + char *header; + + header=storeMatchMime(e,"content-length: ",buf,sizeof(buf)); + if(!header) { + debug(20,1,"storeEntryValidLength: no content-length:%s\n",e->key); + return 0; + } + + length=atoi(header); + if(!length) { + debug(20,1,"storeEntryValidLength: can't parse content-length:%s\n",e->key); + return 0; + } + + headerlength=storeGrep(e,"\r\n\r\n",300); + if(!headerlength) { + debug(20,1,"storeEntryValidLength: can't get headersize:%s\n",e->key); + return 0; + } + + if(length+headerlength != e->object_len) { + debug(20,1,"storeEntryValidLength: invalid content-length: %d+%d!=%d:%s\n" + ,headerlength,length,e->object_len,e->key); + return 0; + } + + return 1; } static int storeVerifySwapDirs(clean) diff -u -r -x *.o -x *.orig -X exclude_files squid-1.0.alpha5/src/store.h squid-1.0.alpha5.henrik/src/store.h --- squid-1.0.alpha5/src/store.h Tue Apr 2 01:34:46 1996 +++ squid-1.0.alpha5.henrik/src/store.h Thu Apr 4 19:56:31 1996 @@ -164,6 +164,7 @@ extern int storeGetSwapSize _PARAMS((void)); extern int storeGetSwapSpace _PARAMS((int)); extern int storeEntryValidToSend _PARAMS((StoreEntry *)); +extern int storeEntryValidLength _PARAMS((StoreEntry *)); extern int storeEntryLocked _PARAMS((StoreEntry *)); extern int storeLockObject _PARAMS((StoreEntry *)); extern int storeOriginalKey _PARAMS((StoreEntry *));