Fossil SCM

In import --git, refuse a data command whose length is not a number below 2147483647. A negative length overflowed the buffer it was read into, and a length near the largest int overflowed the arithmetic for its size.

dmestas 2026-11-20 20:31 UTC small-fixes
Commit 54a4bc1458cafc03b9027835440615ca87e0f7220a4716f1c2111e84289dce08
1 file changed +3
--- src/import.c
+++ src/import.c
@@ -625,10 +625,13 @@
625625
fossil_print("%s\n", &zLine[9]);
626626
fflush(stdout);
627627
}else
628628
if( strncmp(zLine, "data ", 5)==0 ){
629629
fossil_free(gg.aData); gg.aData = 0;
630
+ if( !fossil_isdigit(zLine[5]) || strtoll(&zLine[5], 0, 10)>=0x7fffffff ){
631
+ goto malformed_line;
632
+ }
630633
gg.nData = atoi(&zLine[5]);
631634
if( gg.nData ){
632635
int got;
633636
gg.aData = fossil_malloc( gg.nData+1 );
634637
got = fread(gg.aData, 1, gg.nData, pIn);
635638
--- src/import.c
+++ src/import.c
@@ -625,10 +625,13 @@
625 fossil_print("%s\n", &zLine[9]);
626 fflush(stdout);
627 }else
628 if( strncmp(zLine, "data ", 5)==0 ){
629 fossil_free(gg.aData); gg.aData = 0;
 
 
 
630 gg.nData = atoi(&zLine[5]);
631 if( gg.nData ){
632 int got;
633 gg.aData = fossil_malloc( gg.nData+1 );
634 got = fread(gg.aData, 1, gg.nData, pIn);
635
--- src/import.c
+++ src/import.c
@@ -625,10 +625,13 @@
625 fossil_print("%s\n", &zLine[9]);
626 fflush(stdout);
627 }else
628 if( strncmp(zLine, "data ", 5)==0 ){
629 fossil_free(gg.aData); gg.aData = 0;
630 if( !fossil_isdigit(zLine[5]) || strtoll(&zLine[5], 0, 10)>=0x7fffffff ){
631 goto malformed_line;
632 }
633 gg.nData = atoi(&zLine[5]);
634 if( gg.nData ){
635 int got;
636 gg.aData = fossil_malloc( gg.nData+1 );
637 got = fread(gg.aData, 1, gg.nData, pIn);
638

Keyboard Shortcuts

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