Fossil SCM

Pervent integer overflow caused by a malicious delta.

drh 2025-12-11 23:24 trunk
Commit 2b660bd17402689777da04b4984fdf24cfd71048ade72a92e1b3a9f814f07a8b
1 file changed +1 -1
+1 -1
--- src/delta.c
+++ src/delta.c
@@ -602,11 +602,11 @@
602602
total += cnt;
603603
if( total>limit ){
604604
/* ERROR: copy exceeds output file size */
605605
return -1;
606606
}
607
- if( (int)(ofst+cnt) > lenSrc ){
607
+ if( (u64)ofst+(u64)cnt > (u64)lenSrc ){
608608
/* ERROR: copy extends past end of input */
609609
return -1;
610610
}
611611
memcpy(zOut, &zSrc[ofst], cnt);
612612
zOut += cnt;
613613
--- src/delta.c
+++ src/delta.c
@@ -602,11 +602,11 @@
602 total += cnt;
603 if( total>limit ){
604 /* ERROR: copy exceeds output file size */
605 return -1;
606 }
607 if( (int)(ofst+cnt) > lenSrc ){
608 /* ERROR: copy extends past end of input */
609 return -1;
610 }
611 memcpy(zOut, &zSrc[ofst], cnt);
612 zOut += cnt;
613
--- src/delta.c
+++ src/delta.c
@@ -602,11 +602,11 @@
602 total += cnt;
603 if( total>limit ){
604 /* ERROR: copy exceeds output file size */
605 return -1;
606 }
607 if( (u64)ofst+(u64)cnt > (u64)lenSrc ){
608 /* ERROR: copy extends past end of input */
609 return -1;
610 }
611 memcpy(zOut, &zSrc[ofst], cnt);
612 zOut += cnt;
613

Keyboard Shortcuts

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