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.
Commit
2e20f2fc4ddd2f8a0c95a8bdc68a4bbe0ff183bc5f4d477743a6772ea96cc770
Parent
fbc0065c42a80a6…
1 file changed
+3
-1
+3
-1
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -1038,11 +1038,13 @@ | ||
| 1038 | 1038 | if( size<oldsize ) SYNTAX("size overflow on W-card"); |
| 1039 | 1039 | oldsize = size; |
| 1040 | 1040 | } |
| 1041 | 1041 | if( p->zWiki!=0 ) SYNTAX("more than one W-card"); |
| 1042 | 1042 | 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 | + } | |
| 1044 | 1046 | p->zWiki = x.z; |
| 1045 | 1047 | x.z += size; |
| 1046 | 1048 | if( x.z[0]!='\n' ) SYNTAX("W-card content no \\n terminated"); |
| 1047 | 1049 | x.z[0] = 0; |
| 1048 | 1050 | x.z++; |
| 1049 | 1051 |
| --- 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 |