Fossil SCM

Detect infinite loops in the DELTA table and abort out of content_get() when they are found. Fix an off-by-one error in the version-3 clone protocol. This error might cause an incomplete and corrupt clone if a transfer block fills up just before sending the very last blob. Backport of fixes from [2012-08-23 23:15:36]

drh 2012-11-14 20:28 UTC branch-1.19
Commit 99053ab14108599b4a89cacb47530e44b779004c
2 files changed +3 +1 -1
--- src/content.c
+++ src/content.c
@@ -269,10 +269,13 @@
269269
n = 1;
270270
while( !bag_find(&contentCache.inCache, nextRid)
271271
&& (nextRid = findSrcid(nextRid))>0 ){
272272
n++;
273273
if( n>=nAlloc ){
274
+ if( n>db_int(0, "SELECT max(rid) FROM blob") ){
275
+ fossil_panic("infinite loop in DELTA table");
276
+ }
274277
nAlloc = nAlloc*2 + 10;
275278
a = fossil_realloc(a, nAlloc*sizeof(a[0]));
276279
}
277280
a[n] = nextRid;
278281
}
279282
--- src/content.c
+++ src/content.c
@@ -269,10 +269,13 @@
269 n = 1;
270 while( !bag_find(&contentCache.inCache, nextRid)
271 && (nextRid = findSrcid(nextRid))>0 ){
272 n++;
273 if( n>=nAlloc ){
 
 
 
274 nAlloc = nAlloc*2 + 10;
275 a = fossil_realloc(a, nAlloc*sizeof(a[0]));
276 }
277 a[n] = nextRid;
278 }
279
--- src/content.c
+++ src/content.c
@@ -269,10 +269,13 @@
269 n = 1;
270 while( !bag_find(&contentCache.inCache, nextRid)
271 && (nextRid = findSrcid(nextRid))>0 ){
272 n++;
273 if( n>=nAlloc ){
274 if( n>db_int(0, "SELECT max(rid) FROM blob") ){
275 fossil_panic("infinite loop in DELTA table");
276 }
277 nAlloc = nAlloc*2 + 10;
278 a = fossil_realloc(a, nAlloc*sizeof(a[0]));
279 }
280 a[n] = nextRid;
281 }
282
+1 -1
--- src/xfer.c
+++ src/xfer.c
@@ -994,11 +994,11 @@
994994
}else{
995995
send_file(&xfer, seqno, 0, 1);
996996
}
997997
seqno++;
998998
}
999
- if( seqno>=max ) seqno = 0;
999
+ if( seqno>max ) seqno = 0;
10001000
@ clone_seqno %d(seqno)
10011001
}else{
10021002
isClone = 1;
10031003
isPull = 1;
10041004
deltaFlag = 1;
10051005
--- src/xfer.c
+++ src/xfer.c
@@ -994,11 +994,11 @@
994 }else{
995 send_file(&xfer, seqno, 0, 1);
996 }
997 seqno++;
998 }
999 if( seqno>=max ) seqno = 0;
1000 @ clone_seqno %d(seqno)
1001 }else{
1002 isClone = 1;
1003 isPull = 1;
1004 deltaFlag = 1;
1005
--- src/xfer.c
+++ src/xfer.c
@@ -994,11 +994,11 @@
994 }else{
995 send_file(&xfer, seqno, 0, 1);
996 }
997 seqno++;
998 }
999 if( seqno>max ) seqno = 0;
1000 @ clone_seqno %d(seqno)
1001 }else{
1002 isClone = 1;
1003 isPull = 1;
1004 deltaFlag = 1;
1005

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button