Fossil SCM

In manifest_parse(), compare the size on a W-card with the number of bytes that remain, without adding it to a pointer. A size of 4294967295 wrapped to zero inside the check, was accepted, and moved the parse far past the end of the artifact.

dmestas 2026-11-14 07:04 UTC small-fixes-2
Commit 2e20f2fc4ddd2f8a0c95a8bdc68a4bbe0ff183bc5f4d477743a6772ea96cc770
1 file changed +3 -1
+3 -1
--- src/manifest.c
+++ src/manifest.c
@@ -1038,11 +1038,13 @@
10381038
if( size<oldsize ) SYNTAX("size overflow on W-card");
10391039
oldsize = size;
10401040
}
10411041
if( p->zWiki!=0 ) SYNTAX("more than one W-card");
10421042
blob_zero(&wiki);
1043
- if( (&x.z[size+1])>=x.zEnd )SYNTAX("not enough content after W-card");
1043
+ if( (i64)size+1>=(i64)(x.zEnd-x.z) ){
1044
+ SYNTAX("not enough content after W-card");
1045
+ }
10441046
p->zWiki = x.z;
10451047
x.z += size;
10461048
if( x.z[0]!='\n' ) SYNTAX("W-card content no \\n terminated");
10471049
x.z[0] = 0;
10481050
x.z++;
10491051
--- src/manifest.c
+++ src/manifest.c
@@ -1038,11 +1038,13 @@
1038 if( size<oldsize ) SYNTAX("size overflow on W-card");
1039 oldsize = size;
1040 }
1041 if( p->zWiki!=0 ) SYNTAX("more than one W-card");
1042 blob_zero(&wiki);
1043 if( (&x.z[size+1])>=x.zEnd )SYNTAX("not enough content after W-card");
 
 
1044 p->zWiki = x.z;
1045 x.z += size;
1046 if( x.z[0]!='\n' ) SYNTAX("W-card content no \\n terminated");
1047 x.z[0] = 0;
1048 x.z++;
1049
--- src/manifest.c
+++ src/manifest.c
@@ -1038,11 +1038,13 @@
1038 if( size<oldsize ) SYNTAX("size overflow on W-card");
1039 oldsize = size;
1040 }
1041 if( p->zWiki!=0 ) SYNTAX("more than one W-card");
1042 blob_zero(&wiki);
1043 if( (i64)size+1>=(i64)(x.zEnd-x.z) ){
1044 SYNTAX("not enough content after W-card");
1045 }
1046 p->zWiki = x.z;
1047 x.z += size;
1048 if( x.z[0]!='\n' ) SYNTAX("W-card content no \\n terminated");
1049 x.z[0] = 0;
1050 x.z++;
1051

Keyboard Shortcuts

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