Fossil SCM

Merge small-fixes-2 into trunk: sixteen fixes for crashes, reads past the end of a buffer and missing checks in the artifact parser, the sync client, the svn importer and the markup translators, most of them found by sanitizer builds and fuzzing.

dmestas 2026-11-16 11:38 UTC trunk merge
Commit ffc8eb67a0d892c61872cc5400436991f2d0c3d9f3d36b5cbb3f9b3c44c9b0c8
+1 -1
--- src/dispatch.c
+++ src/dispatch.c
@@ -1120,11 +1120,11 @@
11201120
blob_appendf(&buf, "boolean ");
11211121
}
11221122
blob_appendf(&buf,"setting");
11231123
zDesc = blob_str(&buf);
11241124
}
1125
- if( memcmp(aCommand[i].zName, "test", 4)==0 ) continue;
1125
+ if( strncmp(aCommand[i].zName, "test", 4)==0 ) continue;
11261126
if( occHelp[aCommand[i].iHelp] > 0 ){
11271127
int j;
11281128
for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
11291129
unsigned int e = aCommand[bktHelp[aCommand[i].iHelp][j]].eCmdFlags;
11301130
if( e & CMDFLAG_1ST_TIER ){
11311131
--- src/dispatch.c
+++ src/dispatch.c
@@ -1120,11 +1120,11 @@
1120 blob_appendf(&buf, "boolean ");
1121 }
1122 blob_appendf(&buf,"setting");
1123 zDesc = blob_str(&buf);
1124 }
1125 if( memcmp(aCommand[i].zName, "test", 4)==0 ) continue;
1126 if( occHelp[aCommand[i].iHelp] > 0 ){
1127 int j;
1128 for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
1129 unsigned int e = aCommand[bktHelp[aCommand[i].iHelp][j]].eCmdFlags;
1130 if( e & CMDFLAG_1ST_TIER ){
1131
--- src/dispatch.c
+++ src/dispatch.c
@@ -1120,11 +1120,11 @@
1120 blob_appendf(&buf, "boolean ");
1121 }
1122 blob_appendf(&buf,"setting");
1123 zDesc = blob_str(&buf);
1124 }
1125 if( strncmp(aCommand[i].zName, "test", 4)==0 ) continue;
1126 if( occHelp[aCommand[i].iHelp] > 0 ){
1127 int j;
1128 for(j=0; j<occHelp[aCommand[i].iHelp]; j++){
1129 unsigned int e = aCommand[bktHelp[aCommand[i].iHelp][j]].eCmdFlags;
1130 if( e & CMDFLAG_1ST_TIER ){
1131
+3 -2
--- src/file.c
+++ src/file.c
@@ -1827,13 +1827,14 @@
18271827
if( zPwd[j]=='/' ){
18281828
blob_append(pOut, "/..", 3);
18291829
}
18301830
}
18311831
while( i>0 && (zPwd[i]!='/')) --i;
1832
- blob_append(pOut, zPath+i, j-i);
1832
+ blob_append(pOut, zPath+i, -1);
18331833
}
1834
- if( slash && i>0 && zPath[strlen(zPath)-1]=='/'){
1834
+ if( slash && i>0 && zPath[strlen(zPath)-1]=='/'
1835
+ && blob_buffer(pOut)[blob_size(pOut)-1]!='/' ){
18351836
blob_append(pOut, "/", 1);
18361837
}
18371838
blob_reset(&tmp);
18381839
return;
18391840
}
18401841
--- src/file.c
+++ src/file.c
@@ -1827,13 +1827,14 @@
1827 if( zPwd[j]=='/' ){
1828 blob_append(pOut, "/..", 3);
1829 }
1830 }
1831 while( i>0 && (zPwd[i]!='/')) --i;
1832 blob_append(pOut, zPath+i, j-i);
1833 }
1834 if( slash && i>0 && zPath[strlen(zPath)-1]=='/'){
 
1835 blob_append(pOut, "/", 1);
1836 }
1837 blob_reset(&tmp);
1838 return;
1839 }
1840
--- src/file.c
+++ src/file.c
@@ -1827,13 +1827,14 @@
1827 if( zPwd[j]=='/' ){
1828 blob_append(pOut, "/..", 3);
1829 }
1830 }
1831 while( i>0 && (zPwd[i]!='/')) --i;
1832 blob_append(pOut, zPath+i, -1);
1833 }
1834 if( slash && i>0 && zPath[strlen(zPath)-1]=='/'
1835 && blob_buffer(pOut)[blob_size(pOut)-1]!='/' ){
1836 blob_append(pOut, "/", 1);
1837 }
1838 blob_reset(&tmp);
1839 return;
1840 }
1841
+22 -2
--- src/import.c
+++ src/import.c
@@ -942,37 +942,51 @@
942942
rec->aProps = 0;
943943
rec->nProps = 0;
944944
zLen = svn_find_header(*rec, "Prop-content-length");
945945
if( zLen ){
946946
nRawProps = atoi(zLen);
947
+ if( nRawProps<0 ){
948
+ fossil_fatal("svn-dump data format broken");
949
+ }
947950
}
948951
if( nRawProps ){
949952
int got;
950953
char *zLine;
954
+ char *zEnd; /* Start of the PROPS-END marker */
951955
rec->pRawProps = pRawProps = fossil_malloc( nRawProps );
952956
got = fread(rec->pRawProps, 1, nRawProps, pIn);
953957
if( got!=nRawProps ){
954958
fossil_fatal("short read: got %d of %d bytes", got, nRawProps);
955959
}
956
- if( memcmp(&pRawProps[got-10], "PROPS-END\n", 10)!=0 ){
960
+ if( got<10 || memcmp(&pRawProps[got-10], "PROPS-END\n", 10)!=0 ){
957961
fossil_fatal("svn-dump data ended unexpectedly");
958962
}
959963
zLine = pRawProps;
960
- while( zLine<(pRawProps+nRawProps-10) ){
964
+ zEnd = pRawProps+nRawProps-10;
965
+ while( zLine<zEnd ){
961966
char *eol;
962967
int propLen;
963968
if( zLine[0]=='D' ){
964969
propLen = atoi(&zLine[2]);
965970
eol = strchr(zLine, '\n');
971
+ if( eol==0 || eol>=zEnd || propLen<0 || propLen>zEnd-eol ){
972
+ fossil_fatal("svn-dump data format broken");
973
+ }
966974
zLine = eol+1+propLen+1;
967975
}else{
968976
if( zLine[0]!='K' ){
969977
fossil_fatal("svn-dump data format broken");
970978
}
971979
propLen = atoi(&zLine[2]);
972980
eol = strchr(zLine, '\n');
981
+ if( eol==0 || eol>=zEnd ){
982
+ fossil_fatal("svn-dump data format broken");
983
+ }
973984
zLine = eol+1;
985
+ if( propLen<0 || propLen>=zEnd-zLine ){
986
+ fossil_fatal("svn-dump data format broken");
987
+ }
974988
eol = zLine+propLen;
975989
if( *eol!='\n' ){
976990
fossil_fatal("svn-dump data format broken");
977991
}
978992
*eol = 0;
@@ -984,11 +998,17 @@
984998
if( zLine[0]!='V' ){
985999
fossil_fatal("svn-dump data format broken");
9861000
}
9871001
propLen = atoi(&zLine[2]);
9881002
eol = strchr(zLine, '\n');
1003
+ if( eol==0 || eol>=zEnd ){
1004
+ fossil_fatal("svn-dump data format broken");
1005
+ }
9891006
zLine = eol+1;
1007
+ if( propLen<0 || propLen>=zEnd-zLine ){
1008
+ fossil_fatal("svn-dump data format broken");
1009
+ }
9901010
eol = zLine+propLen;
9911011
if( *eol!='\n' ){
9921012
fossil_fatal("svn-dump data format broken");
9931013
}
9941014
*eol = 0;
9951015
--- src/import.c
+++ src/import.c
@@ -942,37 +942,51 @@
942 rec->aProps = 0;
943 rec->nProps = 0;
944 zLen = svn_find_header(*rec, "Prop-content-length");
945 if( zLen ){
946 nRawProps = atoi(zLen);
 
 
 
947 }
948 if( nRawProps ){
949 int got;
950 char *zLine;
 
951 rec->pRawProps = pRawProps = fossil_malloc( nRawProps );
952 got = fread(rec->pRawProps, 1, nRawProps, pIn);
953 if( got!=nRawProps ){
954 fossil_fatal("short read: got %d of %d bytes", got, nRawProps);
955 }
956 if( memcmp(&pRawProps[got-10], "PROPS-END\n", 10)!=0 ){
957 fossil_fatal("svn-dump data ended unexpectedly");
958 }
959 zLine = pRawProps;
960 while( zLine<(pRawProps+nRawProps-10) ){
 
961 char *eol;
962 int propLen;
963 if( zLine[0]=='D' ){
964 propLen = atoi(&zLine[2]);
965 eol = strchr(zLine, '\n');
 
 
 
966 zLine = eol+1+propLen+1;
967 }else{
968 if( zLine[0]!='K' ){
969 fossil_fatal("svn-dump data format broken");
970 }
971 propLen = atoi(&zLine[2]);
972 eol = strchr(zLine, '\n');
 
 
 
973 zLine = eol+1;
 
 
 
974 eol = zLine+propLen;
975 if( *eol!='\n' ){
976 fossil_fatal("svn-dump data format broken");
977 }
978 *eol = 0;
@@ -984,11 +998,17 @@
984 if( zLine[0]!='V' ){
985 fossil_fatal("svn-dump data format broken");
986 }
987 propLen = atoi(&zLine[2]);
988 eol = strchr(zLine, '\n');
 
 
 
989 zLine = eol+1;
 
 
 
990 eol = zLine+propLen;
991 if( *eol!='\n' ){
992 fossil_fatal("svn-dump data format broken");
993 }
994 *eol = 0;
995
--- src/import.c
+++ src/import.c
@@ -942,37 +942,51 @@
942 rec->aProps = 0;
943 rec->nProps = 0;
944 zLen = svn_find_header(*rec, "Prop-content-length");
945 if( zLen ){
946 nRawProps = atoi(zLen);
947 if( nRawProps<0 ){
948 fossil_fatal("svn-dump data format broken");
949 }
950 }
951 if( nRawProps ){
952 int got;
953 char *zLine;
954 char *zEnd; /* Start of the PROPS-END marker */
955 rec->pRawProps = pRawProps = fossil_malloc( nRawProps );
956 got = fread(rec->pRawProps, 1, nRawProps, pIn);
957 if( got!=nRawProps ){
958 fossil_fatal("short read: got %d of %d bytes", got, nRawProps);
959 }
960 if( got<10 || memcmp(&pRawProps[got-10], "PROPS-END\n", 10)!=0 ){
961 fossil_fatal("svn-dump data ended unexpectedly");
962 }
963 zLine = pRawProps;
964 zEnd = pRawProps+nRawProps-10;
965 while( zLine<zEnd ){
966 char *eol;
967 int propLen;
968 if( zLine[0]=='D' ){
969 propLen = atoi(&zLine[2]);
970 eol = strchr(zLine, '\n');
971 if( eol==0 || eol>=zEnd || propLen<0 || propLen>zEnd-eol ){
972 fossil_fatal("svn-dump data format broken");
973 }
974 zLine = eol+1+propLen+1;
975 }else{
976 if( zLine[0]!='K' ){
977 fossil_fatal("svn-dump data format broken");
978 }
979 propLen = atoi(&zLine[2]);
980 eol = strchr(zLine, '\n');
981 if( eol==0 || eol>=zEnd ){
982 fossil_fatal("svn-dump data format broken");
983 }
984 zLine = eol+1;
985 if( propLen<0 || propLen>=zEnd-zLine ){
986 fossil_fatal("svn-dump data format broken");
987 }
988 eol = zLine+propLen;
989 if( *eol!='\n' ){
990 fossil_fatal("svn-dump data format broken");
991 }
992 *eol = 0;
@@ -984,11 +998,17 @@
998 if( zLine[0]!='V' ){
999 fossil_fatal("svn-dump data format broken");
1000 }
1001 propLen = atoi(&zLine[2]);
1002 eol = strchr(zLine, '\n');
1003 if( eol==0 || eol>=zEnd ){
1004 fossil_fatal("svn-dump data format broken");
1005 }
1006 zLine = eol+1;
1007 if( propLen<0 || propLen>=zEnd-zLine ){
1008 fossil_fatal("svn-dump data format broken");
1009 }
1010 eol = zLine+propLen;
1011 if( *eol!='\n' ){
1012 fossil_fatal("svn-dump data format broken");
1013 }
1014 *eol = 0;
1015
+7 -2
--- src/manifest.c
+++ src/manifest.c
@@ -381,11 +381,14 @@
381381
** Return NULL if there are no more tokens on the current line.
382382
*/
383383
static char *next_token(ManifestText *p, int *pLen){
384384
char *zStart;
385385
int n;
386
- if( p->atEol ) return 0;
386
+ if( p->atEol ){
387
+ if( pLen ) *pLen = 0;
388
+ return 0;
389
+ }
387390
zStart = p->z;
388391
n = strcspn(p->z, " \n");
389392
p->atEol = p->z[n]=='\n';
390393
p->z[n] = 0;
391394
p->z += n+1;
@@ -1035,11 +1038,13 @@
10351038
if( size<oldsize ) SYNTAX("size overflow on W-card");
10361039
oldsize = size;
10371040
}
10381041
if( p->zWiki!=0 ) SYNTAX("more than one W-card");
10391042
blob_zero(&wiki);
1040
- 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
+ }
10411046
p->zWiki = x.z;
10421047
x.z += size;
10431048
if( x.z[0]!='\n' ) SYNTAX("W-card content no \\n terminated");
10441049
x.z[0] = 0;
10451050
x.z++;
10461051
--- src/manifest.c
+++ src/manifest.c
@@ -381,11 +381,14 @@
381 ** Return NULL if there are no more tokens on the current line.
382 */
383 static char *next_token(ManifestText *p, int *pLen){
384 char *zStart;
385 int n;
386 if( p->atEol ) return 0;
 
 
 
387 zStart = p->z;
388 n = strcspn(p->z, " \n");
389 p->atEol = p->z[n]=='\n';
390 p->z[n] = 0;
391 p->z += n+1;
@@ -1035,11 +1038,13 @@
1035 if( size<oldsize ) SYNTAX("size overflow on W-card");
1036 oldsize = size;
1037 }
1038 if( p->zWiki!=0 ) SYNTAX("more than one W-card");
1039 blob_zero(&wiki);
1040 if( (&x.z[size+1])>=x.zEnd )SYNTAX("not enough content after W-card");
 
 
1041 p->zWiki = x.z;
1042 x.z += size;
1043 if( x.z[0]!='\n' ) SYNTAX("W-card content no \\n terminated");
1044 x.z[0] = 0;
1045 x.z++;
1046
--- src/manifest.c
+++ src/manifest.c
@@ -381,11 +381,14 @@
381 ** Return NULL if there are no more tokens on the current line.
382 */
383 static char *next_token(ManifestText *p, int *pLen){
384 char *zStart;
385 int n;
386 if( p->atEol ){
387 if( pLen ) *pLen = 0;
388 return 0;
389 }
390 zStart = p->z;
391 n = strcspn(p->z, " \n");
392 p->atEol = p->z[n]=='\n';
393 p->z[n] = 0;
394 p->z += n+1;
@@ -1035,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
+4 -1
--- src/markdown.c
+++ src/markdown.c
@@ -2207,11 +2207,12 @@
22072207
w = 0;
22082208
22092209
if( i<size && (w = is_empty(data + i, size - i))==0 ){
22102210
return 0; /* non-blank line after tag line */
22112211
}
2212
- return i+w;
2212
+ /* is_empty() counts a newline even when the input ends without one */
2213
+ return i+w>size ? size : i+w;
22132214
}
22142215
22152216
22162217
/* parse_htmlblock -- parsing of inline HTML block */
22172218
static size_t parse_htmlblock(
@@ -2242,10 +2243,11 @@
22422243
i++;
22432244
if( i<size ){
22442245
j = is_empty(data+i, size-i);
22452246
if( j ){
22462247
work_size = i+j;
2248
+ if( work_size>size ) work_size = size;
22472249
if( !rndr->make.blockhtml ) return work_size;
22482250
blob_init(&work, data, work_size);
22492251
rndr->make.blockhtml(ob, &work, rndr->make.opaque);
22502252
return work_size;
22512253
}
@@ -2262,10 +2264,11 @@
22622264
if( i+1<size ){
22632265
i += 1;
22642266
j = is_empty(data+i, size-i);
22652267
if( j ){
22662268
work_size = i+j;
2269
+ if( work_size>size ) work_size = size;
22672270
if( !rndr->make.blockhtml ) return work_size;
22682271
blob_init(&work, data, work_size);
22692272
rndr->make.blockhtml(ob, &work, rndr->make.opaque);
22702273
return work_size;
22712274
}
22722275
--- src/markdown.c
+++ src/markdown.c
@@ -2207,11 +2207,12 @@
2207 w = 0;
2208
2209 if( i<size && (w = is_empty(data + i, size - i))==0 ){
2210 return 0; /* non-blank line after tag line */
2211 }
2212 return i+w;
 
2213 }
2214
2215
2216 /* parse_htmlblock -- parsing of inline HTML block */
2217 static size_t parse_htmlblock(
@@ -2242,10 +2243,11 @@
2242 i++;
2243 if( i<size ){
2244 j = is_empty(data+i, size-i);
2245 if( j ){
2246 work_size = i+j;
 
2247 if( !rndr->make.blockhtml ) return work_size;
2248 blob_init(&work, data, work_size);
2249 rndr->make.blockhtml(ob, &work, rndr->make.opaque);
2250 return work_size;
2251 }
@@ -2262,10 +2264,11 @@
2262 if( i+1<size ){
2263 i += 1;
2264 j = is_empty(data+i, size-i);
2265 if( j ){
2266 work_size = i+j;
 
2267 if( !rndr->make.blockhtml ) return work_size;
2268 blob_init(&work, data, work_size);
2269 rndr->make.blockhtml(ob, &work, rndr->make.opaque);
2270 return work_size;
2271 }
2272
--- src/markdown.c
+++ src/markdown.c
@@ -2207,11 +2207,12 @@
2207 w = 0;
2208
2209 if( i<size && (w = is_empty(data + i, size - i))==0 ){
2210 return 0; /* non-blank line after tag line */
2211 }
2212 /* is_empty() counts a newline even when the input ends without one */
2213 return i+w>size ? size : i+w;
2214 }
2215
2216
2217 /* parse_htmlblock -- parsing of inline HTML block */
2218 static size_t parse_htmlblock(
@@ -2242,10 +2243,11 @@
2243 i++;
2244 if( i<size ){
2245 j = is_empty(data+i, size-i);
2246 if( j ){
2247 work_size = i+j;
2248 if( work_size>size ) work_size = size;
2249 if( !rndr->make.blockhtml ) return work_size;
2250 blob_init(&work, data, work_size);
2251 rndr->make.blockhtml(ob, &work, rndr->make.opaque);
2252 return work_size;
2253 }
@@ -2262,10 +2264,11 @@
2264 if( i+1<size ){
2265 i += 1;
2266 j = is_empty(data+i, size-i);
2267 if( j ){
2268 work_size = i+j;
2269 if( work_size>size ) work_size = size;
2270 if( !rndr->make.blockhtml ) return work_size;
2271 blob_init(&work, data, work_size);
2272 rndr->make.blockhtml(ob, &work, rndr->make.opaque);
2273 return work_size;
2274 }
2275
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -250,12 +250,14 @@
250250
z[j++] = fossil_tolower(z[i]);
251251
}else if( fossil_isspace(z[i]) || z[i]=='-' || z[i]=='_' ){
252252
if( j>0 && z[j-1]!='-' ) z[j++] = '-';
253253
}else if( z[i]=='<' ){
254254
do{ i++; }while( z[i]!=0 && z[i]!='>' );
255
+ if( z[i]==0 ) break;
255256
}else if( z[i]=='&' ){
256257
do{ i++; }while( z[i]!=0 && z[i]!=';' );
258
+ if( z[i]==0 ) break;
257259
}else if( (z[i]&0x80)!=0 ){
258260
z[j++] = z[i];
259261
}
260262
}
261263
if( j>0 && z[j-1]=='-' ) j--;
262264
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -250,12 +250,14 @@
250 z[j++] = fossil_tolower(z[i]);
251 }else if( fossil_isspace(z[i]) || z[i]=='-' || z[i]=='_' ){
252 if( j>0 && z[j-1]!='-' ) z[j++] = '-';
253 }else if( z[i]=='<' ){
254 do{ i++; }while( z[i]!=0 && z[i]!='>' );
 
255 }else if( z[i]=='&' ){
256 do{ i++; }while( z[i]!=0 && z[i]!=';' );
 
257 }else if( (z[i]&0x80)!=0 ){
258 z[j++] = z[i];
259 }
260 }
261 if( j>0 && z[j-1]=='-' ) j--;
262
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -250,12 +250,14 @@
250 z[j++] = fossil_tolower(z[i]);
251 }else if( fossil_isspace(z[i]) || z[i]=='-' || z[i]=='_' ){
252 if( j>0 && z[j-1]!='-' ) z[j++] = '-';
253 }else if( z[i]=='<' ){
254 do{ i++; }while( z[i]!=0 && z[i]!='>' );
255 if( z[i]==0 ) break;
256 }else if( z[i]=='&' ){
257 do{ i++; }while( z[i]!=0 && z[i]!=';' );
258 if( z[i]==0 ) break;
259 }else if( (z[i]&0x80)!=0 ){
260 z[j++] = z[i];
261 }
262 }
263 if( j>0 && z[j-1]=='-' ) j--;
264
+1 -1
--- src/printf.c
+++ src/printf.c
@@ -728,12 +728,12 @@
728728
}else if( xtype==etDYNSTRING ){
729729
zExtra = bufpt;
730730
}else if( xtype==etSTRINGID ){
731731
precision = hash_digits(flag_altform2);
732732
}
733
+ if( limit<0 || (precision>=0 && precision<limit) ) limit = precision;
733734
length = StrNLen32(bufpt, limit);
734
- if( precision>=0 && precision<length ) length = precision;
735735
break;
736736
}
737737
case etBLOB: {
738738
int limit = flag_alternateform ? va_arg(ap, int) : -1;
739739
Blob *pBlob = va_arg(ap, Blob*);
740740
--- src/printf.c
+++ src/printf.c
@@ -728,12 +728,12 @@
728 }else if( xtype==etDYNSTRING ){
729 zExtra = bufpt;
730 }else if( xtype==etSTRINGID ){
731 precision = hash_digits(flag_altform2);
732 }
 
733 length = StrNLen32(bufpt, limit);
734 if( precision>=0 && precision<length ) length = precision;
735 break;
736 }
737 case etBLOB: {
738 int limit = flag_alternateform ? va_arg(ap, int) : -1;
739 Blob *pBlob = va_arg(ap, Blob*);
740
--- src/printf.c
+++ src/printf.c
@@ -728,12 +728,12 @@
728 }else if( xtype==etDYNSTRING ){
729 zExtra = bufpt;
730 }else if( xtype==etSTRINGID ){
731 precision = hash_digits(flag_altform2);
732 }
733 if( limit<0 || (precision>=0 && precision<limit) ) limit = precision;
734 length = StrNLen32(bufpt, limit);
 
735 break;
736 }
737 case etBLOB: {
738 int limit = flag_alternateform ? va_arg(ap, int) : -1;
739 Blob *pBlob = va_arg(ap, Blob*);
740
+1 -1
--- src/printf.c
+++ src/printf.c
@@ -728,12 +728,12 @@
728728
}else if( xtype==etDYNSTRING ){
729729
zExtra = bufpt;
730730
}else if( xtype==etSTRINGID ){
731731
precision = hash_digits(flag_altform2);
732732
}
733
+ if( limit<0 || (precision>=0 && precision<limit) ) limit = precision;
733734
length = StrNLen32(bufpt, limit);
734
- if( precision>=0 && precision<length ) length = precision;
735735
break;
736736
}
737737
case etBLOB: {
738738
int limit = flag_alternateform ? va_arg(ap, int) : -1;
739739
Blob *pBlob = va_arg(ap, Blob*);
740740
--- src/printf.c
+++ src/printf.c
@@ -728,12 +728,12 @@
728 }else if( xtype==etDYNSTRING ){
729 zExtra = bufpt;
730 }else if( xtype==etSTRINGID ){
731 precision = hash_digits(flag_altform2);
732 }
 
733 length = StrNLen32(bufpt, limit);
734 if( precision>=0 && precision<length ) length = precision;
735 break;
736 }
737 case etBLOB: {
738 int limit = flag_alternateform ? va_arg(ap, int) : -1;
739 Blob *pBlob = va_arg(ap, Blob*);
740
--- src/printf.c
+++ src/printf.c
@@ -728,12 +728,12 @@
728 }else if( xtype==etDYNSTRING ){
729 zExtra = bufpt;
730 }else if( xtype==etSTRINGID ){
731 precision = hash_digits(flag_altform2);
732 }
733 if( limit<0 || (precision>=0 && precision<limit) ) limit = precision;
734 length = StrNLen32(bufpt, limit);
 
735 break;
736 }
737 case etBLOB: {
738 int limit = flag_alternateform ? va_arg(ap, int) : -1;
739 Blob *pBlob = va_arg(ap, Blob*);
740
+12 -4
--- src/rebuild.c
+++ src/rebuild.c
@@ -465,12 +465,16 @@
465465
int rid = db_column_int(&s, 0);
466466
int size = db_column_int(&s, 1);
467467
if( size>=0 ){
468468
if( !bag_find(&bagDone, rid) ){
469469
Blob content;
470
- content_get(rid, &content);
471
- rebuild_step(rid, size, &content);
470
+ if( content_get(rid, &content) ){
471
+ rebuild_step(rid, size, &content);
472
+ }else{
473
+ /* The content cannot be rebuilt. Leave the artifact as it is. */
474
+ rebuild_step_done(rid);
475
+ }
472476
}
473477
}else{
474478
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
475479
rebuild_step_done(rid);
476480
}
@@ -1527,12 +1531,16 @@
15271531
int rid = db_column_int(&s, 0);
15281532
int size = db_column_int(&s, 1);
15291533
if( size>=0 ){
15301534
if( !bag_find(&bagDone, rid) ){
15311535
Blob content;
1532
- content_get(rid, &content);
1533
- rebuild_step(rid, size, &content);
1536
+ if( content_get(rid, &content) ){
1537
+ rebuild_step(rid, size, &content);
1538
+ }else{
1539
+ /* The content cannot be rebuilt. Leave the artifact as it is. */
1540
+ rebuild_step_done(rid);
1541
+ }
15341542
}
15351543
}
15361544
}
15371545
db_finalize(&s);
15381546
15391547
--- src/rebuild.c
+++ src/rebuild.c
@@ -465,12 +465,16 @@
465 int rid = db_column_int(&s, 0);
466 int size = db_column_int(&s, 1);
467 if( size>=0 ){
468 if( !bag_find(&bagDone, rid) ){
469 Blob content;
470 content_get(rid, &content);
471 rebuild_step(rid, size, &content);
 
 
 
 
472 }
473 }else{
474 db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
475 rebuild_step_done(rid);
476 }
@@ -1527,12 +1531,16 @@
1527 int rid = db_column_int(&s, 0);
1528 int size = db_column_int(&s, 1);
1529 if( size>=0 ){
1530 if( !bag_find(&bagDone, rid) ){
1531 Blob content;
1532 content_get(rid, &content);
1533 rebuild_step(rid, size, &content);
 
 
 
 
1534 }
1535 }
1536 }
1537 db_finalize(&s);
1538
1539
--- src/rebuild.c
+++ src/rebuild.c
@@ -465,12 +465,16 @@
465 int rid = db_column_int(&s, 0);
466 int size = db_column_int(&s, 1);
467 if( size>=0 ){
468 if( !bag_find(&bagDone, rid) ){
469 Blob content;
470 if( content_get(rid, &content) ){
471 rebuild_step(rid, size, &content);
472 }else{
473 /* The content cannot be rebuilt. Leave the artifact as it is. */
474 rebuild_step_done(rid);
475 }
476 }
477 }else{
478 db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
479 rebuild_step_done(rid);
480 }
@@ -1527,12 +1531,16 @@
1531 int rid = db_column_int(&s, 0);
1532 int size = db_column_int(&s, 1);
1533 if( size>=0 ){
1534 if( !bag_find(&bagDone, rid) ){
1535 Blob content;
1536 if( content_get(rid, &content) ){
1537 rebuild_step(rid, size, &content);
1538 }else{
1539 /* The content cannot be rebuilt. Leave the artifact as it is. */
1540 rebuild_step_done(rid);
1541 }
1542 }
1543 }
1544 }
1545 db_finalize(&s);
1546
1547
+2 -2
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -210,12 +210,12 @@
210210
** the connection to the repository database is opened. Set up the
211211
** database connection to be more useful to the human operator.
212212
*/
213213
static int sqlcmd_autoinit(
214214
sqlite3 *db,
215
- const char **pzErrMsg,
216
- const void *notUsed
215
+ char **pzErrMsg,
216
+ const sqlite3_api_routines *notUsed
217217
){
218218
int mTrace = SQLITE_TRACE_CLOSE;
219219
add_content_sql_commands(db);
220220
db_add_aux_functions(db);
221221
re_add_sql_func(db);
222222
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -210,12 +210,12 @@
210 ** the connection to the repository database is opened. Set up the
211 ** database connection to be more useful to the human operator.
212 */
213 static int sqlcmd_autoinit(
214 sqlite3 *db,
215 const char **pzErrMsg,
216 const void *notUsed
217 ){
218 int mTrace = SQLITE_TRACE_CLOSE;
219 add_content_sql_commands(db);
220 db_add_aux_functions(db);
221 re_add_sql_func(db);
222
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -210,12 +210,12 @@
210 ** the connection to the repository database is opened. Set up the
211 ** database connection to be more useful to the human operator.
212 */
213 static int sqlcmd_autoinit(
214 sqlite3 *db,
215 char **pzErrMsg,
216 const sqlite3_api_routines *notUsed
217 ){
218 int mTrace = SQLITE_TRACE_CLOSE;
219 add_content_sql_commands(db);
220 db_add_aux_functions(db);
221 re_add_sql_func(db);
222
+3 -3
--- src/th_main.c
+++ src/th_main.c
@@ -1605,11 +1605,11 @@
16051605
void *p,
16061606
int argc,
16071607
const char **argv,
16081608
int *argl
16091609
){
1610
- if( argc!=4 || memcmp(argv[1],"link",5)!=0 ){
1610
+ if( argc!=4 || strncmp(argv[1],"link",5)!=0 ){
16111611
return Th_WrongNumArgs(interp, "submenu link LABEL URL");
16121612
}
16131613
if( argl[2]==0 ){
16141614
Th_SetResult(interp, "link's LABEL is empty", -1);
16151615
return TH_ERROR;
@@ -2725,11 +2725,11 @@
27252725
/*
27262726
** Make sure that the TH1 script error was not caused by a "missing"
27272727
** command hook handler as that is not actually an error condition.
27282728
*/
27292729
nResult = TH1_LEN(nResult);
2730
- if( memcmp(zResult, NO_COMMAND_HOOK_ERROR, nResult)!=0 ){
2730
+ if( strncmp(zResult, NO_COMMAND_HOOK_ERROR, nResult)!=0 ){
27312731
sendError(0,zResult, nResult, 0);
27322732
}else{
27332733
/*
27342734
** There is no command hook handler "installed". This situation
27352735
** is NOT actually an error.
@@ -2813,11 +2813,11 @@
28132813
/*
28142814
** Make sure that the TH1 script error was not caused by a "missing"
28152815
** webpage hook handler as that is not actually an error condition.
28162816
*/
28172817
nResult = TH1_LEN(nResult);
2818
- if( memcmp(zResult, NO_WEBPAGE_HOOK_ERROR, nResult)!=0 ){
2818
+ if( strncmp(zResult, NO_WEBPAGE_HOOK_ERROR, nResult)!=0 ){
28192819
sendError(0,zResult, nResult, 1);
28202820
}else{
28212821
/*
28222822
** There is no webpage hook handler "installed". This situation
28232823
** is NOT actually an error.
28242824
--- src/th_main.c
+++ src/th_main.c
@@ -1605,11 +1605,11 @@
1605 void *p,
1606 int argc,
1607 const char **argv,
1608 int *argl
1609 ){
1610 if( argc!=4 || memcmp(argv[1],"link",5)!=0 ){
1611 return Th_WrongNumArgs(interp, "submenu link LABEL URL");
1612 }
1613 if( argl[2]==0 ){
1614 Th_SetResult(interp, "link's LABEL is empty", -1);
1615 return TH_ERROR;
@@ -2725,11 +2725,11 @@
2725 /*
2726 ** Make sure that the TH1 script error was not caused by a "missing"
2727 ** command hook handler as that is not actually an error condition.
2728 */
2729 nResult = TH1_LEN(nResult);
2730 if( memcmp(zResult, NO_COMMAND_HOOK_ERROR, nResult)!=0 ){
2731 sendError(0,zResult, nResult, 0);
2732 }else{
2733 /*
2734 ** There is no command hook handler "installed". This situation
2735 ** is NOT actually an error.
@@ -2813,11 +2813,11 @@
2813 /*
2814 ** Make sure that the TH1 script error was not caused by a "missing"
2815 ** webpage hook handler as that is not actually an error condition.
2816 */
2817 nResult = TH1_LEN(nResult);
2818 if( memcmp(zResult, NO_WEBPAGE_HOOK_ERROR, nResult)!=0 ){
2819 sendError(0,zResult, nResult, 1);
2820 }else{
2821 /*
2822 ** There is no webpage hook handler "installed". This situation
2823 ** is NOT actually an error.
2824
--- src/th_main.c
+++ src/th_main.c
@@ -1605,11 +1605,11 @@
1605 void *p,
1606 int argc,
1607 const char **argv,
1608 int *argl
1609 ){
1610 if( argc!=4 || strncmp(argv[1],"link",5)!=0 ){
1611 return Th_WrongNumArgs(interp, "submenu link LABEL URL");
1612 }
1613 if( argl[2]==0 ){
1614 Th_SetResult(interp, "link's LABEL is empty", -1);
1615 return TH_ERROR;
@@ -2725,11 +2725,11 @@
2725 /*
2726 ** Make sure that the TH1 script error was not caused by a "missing"
2727 ** command hook handler as that is not actually an error condition.
2728 */
2729 nResult = TH1_LEN(nResult);
2730 if( strncmp(zResult, NO_COMMAND_HOOK_ERROR, nResult)!=0 ){
2731 sendError(0,zResult, nResult, 0);
2732 }else{
2733 /*
2734 ** There is no command hook handler "installed". This situation
2735 ** is NOT actually an error.
@@ -2813,11 +2813,11 @@
2813 /*
2814 ** Make sure that the TH1 script error was not caused by a "missing"
2815 ** webpage hook handler as that is not actually an error condition.
2816 */
2817 nResult = TH1_LEN(nResult);
2818 if( strncmp(zResult, NO_WEBPAGE_HOOK_ERROR, nResult)!=0 ){
2819 sendError(0,zResult, nResult, 1);
2820 }else{
2821 /*
2822 ** There is no webpage hook handler "installed". This situation
2823 ** is NOT actually an error.
2824
+1 -1
--- src/timeline.c
+++ src/timeline.c
@@ -269,11 +269,11 @@
269269
const char *z = zTagList;
270270
Blob links;
271271
blob_zero(&links);
272272
while( z && z[0] ){
273273
for(i=0; z[i] && (z[i]!=',' || z[i+1]!=' '); i++){}
274
- if( zThisTag==0 || memcmp(z, zThisTag, i)!=0 || zThisTag[i]!=0 ){
274
+ if( zThisTag==0 || strncmp(z, zThisTag, i)!=0 || zThisTag[i]!=0 ){
275275
blob_appendf(&links,
276276
"%z%#h</a>%.2s",
277277
href("%R/timeline?r=%#t&c=%t",i,z,zDate), i,z, &z[i]
278278
);
279279
}else{
280280
--- src/timeline.c
+++ src/timeline.c
@@ -269,11 +269,11 @@
269 const char *z = zTagList;
270 Blob links;
271 blob_zero(&links);
272 while( z && z[0] ){
273 for(i=0; z[i] && (z[i]!=',' || z[i+1]!=' '); i++){}
274 if( zThisTag==0 || memcmp(z, zThisTag, i)!=0 || zThisTag[i]!=0 ){
275 blob_appendf(&links,
276 "%z%#h</a>%.2s",
277 href("%R/timeline?r=%#t&c=%t",i,z,zDate), i,z, &z[i]
278 );
279 }else{
280
--- src/timeline.c
+++ src/timeline.c
@@ -269,11 +269,11 @@
269 const char *z = zTagList;
270 Blob links;
271 blob_zero(&links);
272 while( z && z[0] ){
273 for(i=0; z[i] && (z[i]!=',' || z[i+1]!=' '); i++){}
274 if( zThisTag==0 || strncmp(z, zThisTag, i)!=0 || zThisTag[i]!=0 ){
275 blob_appendf(&links,
276 "%z%#h</a>%.2s",
277 href("%R/timeline?r=%#t&c=%t",i,z,zDate), i,z, &z[i]
278 );
279 }else{
280
+16 -2
--- src/util.c
+++ src/util.c
@@ -769,24 +769,38 @@
769769
if( zTempDirA ) fossil_path_free(zTempDirA);
770770
#endif
771771
return zTFile;
772772
}
773773
774
+/*
775
+** FOSSIL_ASAN is defined if this is a build with AddressSanitizer, which
776
+** needs more address space for its own use than the heap limit allows.
777
+*/
778
+#if defined(__SANITIZE_ADDRESS__)
779
+# define FOSSIL_ASAN 1
780
+#elif defined(__has_feature)
781
+# if __has_feature(address_sanitizer)
782
+# define FOSSIL_ASAN 1
783
+# endif
784
+#endif
785
+
774786
/*
775787
** Turn memory limits for stack and heap on and off. The argument
776788
** is true to turn memory limits on and false to turn them off.
777789
**
778790
** Memory limits should be enabled at startup, but then turned off
779791
** before starting subprocesses.
780792
*/
781793
void fossil_limit_memory(int onOff){
782794
#if defined(__unix__)
795
+#if defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN)
783796
static sqlite3_int64 origHeap = 10000000000LL; /* 10GB */
797
+#endif
784798
static sqlite3_int64 origStack = 8000000 ; /* 8MB */
785799
struct rlimit x;
786800
787
-#if defined(RLIMIT_DATA)
801
+#if defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN)
788802
getrlimit(RLIMIT_DATA, &x);
789803
if( onOff ){
790804
origHeap = x.rlim_cur;
791805
if( sizeof(void*)<8 || sizeof(x.rlim_cur)<8 ){
792806
x.rlim_cur = 1000000000 ; /* 1GB on 32-bit systems */
@@ -795,11 +809,11 @@
795809
}
796810
}else{
797811
x.rlim_cur = origHeap;
798812
}
799813
setrlimit(RLIMIT_DATA, &x);
800
-#endif /* defined(RLIMIT_DATA) */
814
+#endif /* defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) */
801815
#if defined(RLIMIT_STACK)
802816
getrlimit(RLIMIT_STACK, &x);
803817
if( onOff ){
804818
origStack = x.rlim_cur;
805819
x.rlim_cur = 8000000; /* 8MB */
806820
--- src/util.c
+++ src/util.c
@@ -769,24 +769,38 @@
769 if( zTempDirA ) fossil_path_free(zTempDirA);
770 #endif
771 return zTFile;
772 }
773
 
 
 
 
 
 
 
 
 
 
 
 
774 /*
775 ** Turn memory limits for stack and heap on and off. The argument
776 ** is true to turn memory limits on and false to turn them off.
777 **
778 ** Memory limits should be enabled at startup, but then turned off
779 ** before starting subprocesses.
780 */
781 void fossil_limit_memory(int onOff){
782 #if defined(__unix__)
 
783 static sqlite3_int64 origHeap = 10000000000LL; /* 10GB */
 
784 static sqlite3_int64 origStack = 8000000 ; /* 8MB */
785 struct rlimit x;
786
787 #if defined(RLIMIT_DATA)
788 getrlimit(RLIMIT_DATA, &x);
789 if( onOff ){
790 origHeap = x.rlim_cur;
791 if( sizeof(void*)<8 || sizeof(x.rlim_cur)<8 ){
792 x.rlim_cur = 1000000000 ; /* 1GB on 32-bit systems */
@@ -795,11 +809,11 @@
795 }
796 }else{
797 x.rlim_cur = origHeap;
798 }
799 setrlimit(RLIMIT_DATA, &x);
800 #endif /* defined(RLIMIT_DATA) */
801 #if defined(RLIMIT_STACK)
802 getrlimit(RLIMIT_STACK, &x);
803 if( onOff ){
804 origStack = x.rlim_cur;
805 x.rlim_cur = 8000000; /* 8MB */
806
--- src/util.c
+++ src/util.c
@@ -769,24 +769,38 @@
769 if( zTempDirA ) fossil_path_free(zTempDirA);
770 #endif
771 return zTFile;
772 }
773
774 /*
775 ** FOSSIL_ASAN is defined if this is a build with AddressSanitizer, which
776 ** needs more address space for its own use than the heap limit allows.
777 */
778 #if defined(__SANITIZE_ADDRESS__)
779 # define FOSSIL_ASAN 1
780 #elif defined(__has_feature)
781 # if __has_feature(address_sanitizer)
782 # define FOSSIL_ASAN 1
783 # endif
784 #endif
785
786 /*
787 ** Turn memory limits for stack and heap on and off. The argument
788 ** is true to turn memory limits on and false to turn them off.
789 **
790 ** Memory limits should be enabled at startup, but then turned off
791 ** before starting subprocesses.
792 */
793 void fossil_limit_memory(int onOff){
794 #if defined(__unix__)
795 #if defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN)
796 static sqlite3_int64 origHeap = 10000000000LL; /* 10GB */
797 #endif
798 static sqlite3_int64 origStack = 8000000 ; /* 8MB */
799 struct rlimit x;
800
801 #if defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN)
802 getrlimit(RLIMIT_DATA, &x);
803 if( onOff ){
804 origHeap = x.rlim_cur;
805 if( sizeof(void*)<8 || sizeof(x.rlim_cur)<8 ){
806 x.rlim_cur = 1000000000 ; /* 1GB on 32-bit systems */
@@ -795,11 +809,11 @@
809 }
810 }else{
811 x.rlim_cur = origHeap;
812 }
813 setrlimit(RLIMIT_DATA, &x);
814 #endif /* defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) */
815 #if defined(RLIMIT_STACK)
816 getrlimit(RLIMIT_STACK, &x);
817 if( onOff ){
818 origStack = x.rlim_cur;
819 x.rlim_cur = 8000000; /* 8MB */
820
+1 -1
--- src/vfile.c
+++ src/vfile.c
@@ -417,11 +417,11 @@
417417
return 1;
418418
}
419419
if( zName[0]!='-' ) continue;
420420
for(i=0; i<count(azTemp); i++){
421421
n = (int)strlen(azTemp[i]);
422
- if( memcmp(azTemp[i], zName+1, n) ) continue;
422
+ if( strncmp(azTemp[i], zName+1, n) ) continue;
423423
if( zName[n+1]==0 ) return 1;
424424
if( zName[n+1]=='-' ){
425425
for(j=n+2; zName[j] && fossil_isdigit(zName[j]); j++){}
426426
if( zName[j]==0 ) return 1;
427427
}
428428
--- src/vfile.c
+++ src/vfile.c
@@ -417,11 +417,11 @@
417 return 1;
418 }
419 if( zName[0]!='-' ) continue;
420 for(i=0; i<count(azTemp); i++){
421 n = (int)strlen(azTemp[i]);
422 if( memcmp(azTemp[i], zName+1, n) ) continue;
423 if( zName[n+1]==0 ) return 1;
424 if( zName[n+1]=='-' ){
425 for(j=n+2; zName[j] && fossil_isdigit(zName[j]); j++){}
426 if( zName[j]==0 ) return 1;
427 }
428
--- src/vfile.c
+++ src/vfile.c
@@ -417,11 +417,11 @@
417 return 1;
418 }
419 if( zName[0]!='-' ) continue;
420 for(i=0; i<count(azTemp); i++){
421 n = (int)strlen(azTemp[i]);
422 if( strncmp(azTemp[i], zName+1, n) ) continue;
423 if( zName[n+1]==0 ) return 1;
424 if( zName[n+1]=='-' ){
425 for(j=n+2; zName[j] && fossil_isdigit(zName[j]); j++){}
426 if( zName[j]==0 ) return 1;
427 }
428
+10 -9
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -959,25 +959,26 @@
959959
i++;
960960
zValue = &z[i];
961961
while( z[i] && z[i]!='\'' ){ i++; }
962962
}else{
963963
zValue = &z[i];
964
- while( !fossil_isspace(z[i]) && z[i]!='>' ){
964
+ while( z[i] && !fossil_isspace(z[i]) && z[i]!='>' ){
965965
if( z[i]=='\'' || z[i]=='"' ) attrOk = 0;
966966
i++;
967967
}
968968
}
969
+ /* c is the character that ended the value. It has to be noted
970
+ ** even for an attribute that is ignored, or the ">" that ends the
971
+ ** markup is stepped over and the text after it is parsed as more
972
+ ** attributes. */
973
+ c = z[i];
969974
if( attrOk ){
970975
p->aAttr[p->nAttr].zValue = zValue;
971
- p->aAttr[p->nAttr].cTerm = c = z[i];
972
- if( z[i]==0 ){
973
- i--;
974
- }else{
975
- z[i] = 0;
976
- }
977
- }
978
- i++;
976
+ p->aAttr[p->nAttr].cTerm = c;
977
+ if( c ) z[i] = 0;
978
+ }
979
+ if( c ) i++;
979980
}
980981
if( attrOk ){
981982
if( aAttribute[iACode].iMask ) seen |= aAttribute[iACode].iMask;
982983
p->nAttr++;
983984
}
984985
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -959,25 +959,26 @@
959 i++;
960 zValue = &z[i];
961 while( z[i] && z[i]!='\'' ){ i++; }
962 }else{
963 zValue = &z[i];
964 while( !fossil_isspace(z[i]) && z[i]!='>' ){
965 if( z[i]=='\'' || z[i]=='"' ) attrOk = 0;
966 i++;
967 }
968 }
 
 
 
 
 
969 if( attrOk ){
970 p->aAttr[p->nAttr].zValue = zValue;
971 p->aAttr[p->nAttr].cTerm = c = z[i];
972 if( z[i]==0 ){
973 i--;
974 }else{
975 z[i] = 0;
976 }
977 }
978 i++;
979 }
980 if( attrOk ){
981 if( aAttribute[iACode].iMask ) seen |= aAttribute[iACode].iMask;
982 p->nAttr++;
983 }
984
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -959,25 +959,26 @@
959 i++;
960 zValue = &z[i];
961 while( z[i] && z[i]!='\'' ){ i++; }
962 }else{
963 zValue = &z[i];
964 while( z[i] && !fossil_isspace(z[i]) && z[i]!='>' ){
965 if( z[i]=='\'' || z[i]=='"' ) attrOk = 0;
966 i++;
967 }
968 }
969 /* c is the character that ended the value. It has to be noted
970 ** even for an attribute that is ignored, or the ">" that ends the
971 ** markup is stepped over and the text after it is parsed as more
972 ** attributes. */
973 c = z[i];
974 if( attrOk ){
975 p->aAttr[p->nAttr].zValue = zValue;
976 p->aAttr[p->nAttr].cTerm = c;
977 if( c ) z[i] = 0;
978 }
979 if( c ) i++;
 
 
 
 
980 }
981 if( attrOk ){
982 if( aAttribute[iACode].iMask ) seen |= aAttribute[iACode].iMask;
983 p->nAttr++;
984 }
985
+18 -7
--- src/xfer.c
+++ src/xfer.c
@@ -749,11 +749,11 @@
749749
if( db_step(&q1)==SQLITE_ROW ){
750750
sqlite3_int64 mtime = db_column_int64(&q1, 0);
751751
const char *zHash = db_column_text(&q1, 1);
752752
if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){
753753
xfer_cannot_send_sha3_error(pXfer);
754
- db_reset(&q1);
754
+ db_finalize(&q1);
755755
return;
756756
}
757757
if( isFull ){
758758
/* If we have already reached the send size limit, send a (short)
759759
** uvigot card rather than a uvfile card. This only happens on the
@@ -2563,30 +2563,36 @@
25632563
/* file HASH SIZE \n CONTENT
25642564
** file HASH DELTASRC SIZE \n CONTENT
25652565
**
25662566
** Client receives a file transmitted from the server.
25672567
*/
2568
- if( blob_eq(&xfer.aToken[0],"file") ){
2568
+ if( blob_eq(&xfer.aToken[0],"file")
2569
+ && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0
2570
+ ){
25692571
xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
25702572
nArtifactRcvd++;
25712573
}else
25722574
25732575
/* cfile HASH USIZE CSIZE \n CONTENT
25742576
** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
25752577
**
25762578
** Client receives a compressed file transmitted from the server.
25772579
*/
2578
- if( blob_eq(&xfer.aToken[0],"cfile") ){
2580
+ if( blob_eq(&xfer.aToken[0],"cfile")
2581
+ && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0
2582
+ ){
25792583
xfer_accept_compressed_file(&xfer, 0, 0);
25802584
nArtifactRcvd++;
25812585
}else
25822586
25832587
/* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
25842588
**
25852589
** Client accepts an unversioned file from the server.
25862590
*/
2587
- if( blob_eq(&xfer.aToken[0], "uvfile") ){
2591
+ if( blob_eq(&xfer.aToken[0], "uvfile")
2592
+ && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0
2593
+ ){
25882594
xfer_accept_unversioned_file(&xfer, 1);
25892595
nArtifactRcvd++;
25902596
nUvFileRcvd++;
25912597
if( syncFlags & SYNC_VERBOSE ){
25922598
fossil_print("\rUnversioned-file received: %s\n",
@@ -2633,14 +2639,18 @@
26332639
){
26342640
int rid;
26352641
int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1");
26362642
rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
26372643
if( rid>0 ){
2638
- if( isPriv ){
2639
- content_make_private(rid);
2640
- }else{
2644
+ if( !isPriv ){
26412645
content_make_public(rid);
2646
+ }else if( g.perm.Private
2647
+ || db_exists("SELECT 1 FROM phantom WHERE rid=%d", rid) ){
2648
+ /* Outside a sync of private content, only an artifact that is
2649
+ ** still a phantom here is marked, so that it is not asked for
2650
+ ** again. Content that this repository holds stays public. */
2651
+ content_make_private(rid);
26422652
}
26432653
}else if( isPriv && !g.perm.Private ){
26442654
/* ignore private files */
26452655
}else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){
26462656
rid = content_new(blob_str(&xfer.aToken[1]), isPriv);
@@ -2662,10 +2672,11 @@
26622672
** (indicating that the file has been deleted) and MTIME is newer,
26632673
** then do the deletion.
26642674
*/
26652675
if( xfer.nToken==5
26662676
&& blob_eq(&xfer.aToken[0], "uvigot")
2677
+ && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0
26672678
&& blob_is_filename(&xfer.aToken[1])
26682679
&& blob_is_int64(&xfer.aToken[2], &mtime)
26692680
&& blob_is_int(&xfer.aToken[4], &size)
26702681
&& (blob_eq(&xfer.aToken[3],"-") || blob_is_hname(&xfer.aToken[3]))
26712682
){
26722683
--- src/xfer.c
+++ src/xfer.c
@@ -749,11 +749,11 @@
749 if( db_step(&q1)==SQLITE_ROW ){
750 sqlite3_int64 mtime = db_column_int64(&q1, 0);
751 const char *zHash = db_column_text(&q1, 1);
752 if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){
753 xfer_cannot_send_sha3_error(pXfer);
754 db_reset(&q1);
755 return;
756 }
757 if( isFull ){
758 /* If we have already reached the send size limit, send a (short)
759 ** uvigot card rather than a uvfile card. This only happens on the
@@ -2563,30 +2563,36 @@
2563 /* file HASH SIZE \n CONTENT
2564 ** file HASH DELTASRC SIZE \n CONTENT
2565 **
2566 ** Client receives a file transmitted from the server.
2567 */
2568 if( blob_eq(&xfer.aToken[0],"file") ){
 
 
2569 xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
2570 nArtifactRcvd++;
2571 }else
2572
2573 /* cfile HASH USIZE CSIZE \n CONTENT
2574 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
2575 **
2576 ** Client receives a compressed file transmitted from the server.
2577 */
2578 if( blob_eq(&xfer.aToken[0],"cfile") ){
 
 
2579 xfer_accept_compressed_file(&xfer, 0, 0);
2580 nArtifactRcvd++;
2581 }else
2582
2583 /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
2584 **
2585 ** Client accepts an unversioned file from the server.
2586 */
2587 if( blob_eq(&xfer.aToken[0], "uvfile") ){
 
 
2588 xfer_accept_unversioned_file(&xfer, 1);
2589 nArtifactRcvd++;
2590 nUvFileRcvd++;
2591 if( syncFlags & SYNC_VERBOSE ){
2592 fossil_print("\rUnversioned-file received: %s\n",
@@ -2633,14 +2639,18 @@
2633 ){
2634 int rid;
2635 int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1");
2636 rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
2637 if( rid>0 ){
2638 if( isPriv ){
2639 content_make_private(rid);
2640 }else{
2641 content_make_public(rid);
 
 
 
 
 
 
2642 }
2643 }else if( isPriv && !g.perm.Private ){
2644 /* ignore private files */
2645 }else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){
2646 rid = content_new(blob_str(&xfer.aToken[1]), isPriv);
@@ -2662,10 +2672,11 @@
2662 ** (indicating that the file has been deleted) and MTIME is newer,
2663 ** then do the deletion.
2664 */
2665 if( xfer.nToken==5
2666 && blob_eq(&xfer.aToken[0], "uvigot")
 
2667 && blob_is_filename(&xfer.aToken[1])
2668 && blob_is_int64(&xfer.aToken[2], &mtime)
2669 && blob_is_int(&xfer.aToken[4], &size)
2670 && (blob_eq(&xfer.aToken[3],"-") || blob_is_hname(&xfer.aToken[3]))
2671 ){
2672
--- src/xfer.c
+++ src/xfer.c
@@ -749,11 +749,11 @@
749 if( db_step(&q1)==SQLITE_ROW ){
750 sqlite3_int64 mtime = db_column_int64(&q1, 0);
751 const char *zHash = db_column_text(&q1, 1);
752 if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){
753 xfer_cannot_send_sha3_error(pXfer);
754 db_finalize(&q1);
755 return;
756 }
757 if( isFull ){
758 /* If we have already reached the send size limit, send a (short)
759 ** uvigot card rather than a uvfile card. This only happens on the
@@ -2563,30 +2563,36 @@
2563 /* file HASH SIZE \n CONTENT
2564 ** file HASH DELTASRC SIZE \n CONTENT
2565 **
2566 ** Client receives a file transmitted from the server.
2567 */
2568 if( blob_eq(&xfer.aToken[0],"file")
2569 && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0
2570 ){
2571 xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
2572 nArtifactRcvd++;
2573 }else
2574
2575 /* cfile HASH USIZE CSIZE \n CONTENT
2576 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
2577 **
2578 ** Client receives a compressed file transmitted from the server.
2579 */
2580 if( blob_eq(&xfer.aToken[0],"cfile")
2581 && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0
2582 ){
2583 xfer_accept_compressed_file(&xfer, 0, 0);
2584 nArtifactRcvd++;
2585 }else
2586
2587 /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
2588 **
2589 ** Client accepts an unversioned file from the server.
2590 */
2591 if( blob_eq(&xfer.aToken[0], "uvfile")
2592 && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0
2593 ){
2594 xfer_accept_unversioned_file(&xfer, 1);
2595 nArtifactRcvd++;
2596 nUvFileRcvd++;
2597 if( syncFlags & SYNC_VERBOSE ){
2598 fossil_print("\rUnversioned-file received: %s\n",
@@ -2633,14 +2639,18 @@
2639 ){
2640 int rid;
2641 int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1");
2642 rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
2643 if( rid>0 ){
2644 if( !isPriv ){
 
 
2645 content_make_public(rid);
2646 }else if( g.perm.Private
2647 || db_exists("SELECT 1 FROM phantom WHERE rid=%d", rid) ){
2648 /* Outside a sync of private content, only an artifact that is
2649 ** still a phantom here is marked, so that it is not asked for
2650 ** again. Content that this repository holds stays public. */
2651 content_make_private(rid);
2652 }
2653 }else if( isPriv && !g.perm.Private ){
2654 /* ignore private files */
2655 }else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){
2656 rid = content_new(blob_str(&xfer.aToken[1]), isPriv);
@@ -2662,10 +2672,11 @@
2672 ** (indicating that the file has been deleted) and MTIME is newer,
2673 ** then do the deletion.
2674 */
2675 if( xfer.nToken==5
2676 && blob_eq(&xfer.aToken[0], "uvigot")
2677 && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0
2678 && blob_is_filename(&xfer.aToken[1])
2679 && blob_is_int64(&xfer.aToken[2], &mtime)
2680 && blob_is_int(&xfer.aToken[4], &size)
2681 && (blob_eq(&xfer.aToken[3],"-") || blob_is_hname(&xfer.aToken[3]))
2682 ){
2683
+18 -7
--- src/xfer.c
+++ src/xfer.c
@@ -749,11 +749,11 @@
749749
if( db_step(&q1)==SQLITE_ROW ){
750750
sqlite3_int64 mtime = db_column_int64(&q1, 0);
751751
const char *zHash = db_column_text(&q1, 1);
752752
if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){
753753
xfer_cannot_send_sha3_error(pXfer);
754
- db_reset(&q1);
754
+ db_finalize(&q1);
755755
return;
756756
}
757757
if( isFull ){
758758
/* If we have already reached the send size limit, send a (short)
759759
** uvigot card rather than a uvfile card. This only happens on the
@@ -2563,30 +2563,36 @@
25632563
/* file HASH SIZE \n CONTENT
25642564
** file HASH DELTASRC SIZE \n CONTENT
25652565
**
25662566
** Client receives a file transmitted from the server.
25672567
*/
2568
- if( blob_eq(&xfer.aToken[0],"file") ){
2568
+ if( blob_eq(&xfer.aToken[0],"file")
2569
+ && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0
2570
+ ){
25692571
xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
25702572
nArtifactRcvd++;
25712573
}else
25722574
25732575
/* cfile HASH USIZE CSIZE \n CONTENT
25742576
** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
25752577
**
25762578
** Client receives a compressed file transmitted from the server.
25772579
*/
2578
- if( blob_eq(&xfer.aToken[0],"cfile") ){
2580
+ if( blob_eq(&xfer.aToken[0],"cfile")
2581
+ && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0
2582
+ ){
25792583
xfer_accept_compressed_file(&xfer, 0, 0);
25802584
nArtifactRcvd++;
25812585
}else
25822586
25832587
/* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
25842588
**
25852589
** Client accepts an unversioned file from the server.
25862590
*/
2587
- if( blob_eq(&xfer.aToken[0], "uvfile") ){
2591
+ if( blob_eq(&xfer.aToken[0], "uvfile")
2592
+ && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0
2593
+ ){
25882594
xfer_accept_unversioned_file(&xfer, 1);
25892595
nArtifactRcvd++;
25902596
nUvFileRcvd++;
25912597
if( syncFlags & SYNC_VERBOSE ){
25922598
fossil_print("\rUnversioned-file received: %s\n",
@@ -2633,14 +2639,18 @@
26332639
){
26342640
int rid;
26352641
int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1");
26362642
rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
26372643
if( rid>0 ){
2638
- if( isPriv ){
2639
- content_make_private(rid);
2640
- }else{
2644
+ if( !isPriv ){
26412645
content_make_public(rid);
2646
+ }else if( g.perm.Private
2647
+ || db_exists("SELECT 1 FROM phantom WHERE rid=%d", rid) ){
2648
+ /* Outside a sync of private content, only an artifact that is
2649
+ ** still a phantom here is marked, so that it is not asked for
2650
+ ** again. Content that this repository holds stays public. */
2651
+ content_make_private(rid);
26422652
}
26432653
}else if( isPriv && !g.perm.Private ){
26442654
/* ignore private files */
26452655
}else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){
26462656
rid = content_new(blob_str(&xfer.aToken[1]), isPriv);
@@ -2662,10 +2672,11 @@
26622672
** (indicating that the file has been deleted) and MTIME is newer,
26632673
** then do the deletion.
26642674
*/
26652675
if( xfer.nToken==5
26662676
&& blob_eq(&xfer.aToken[0], "uvigot")
2677
+ && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0
26672678
&& blob_is_filename(&xfer.aToken[1])
26682679
&& blob_is_int64(&xfer.aToken[2], &mtime)
26692680
&& blob_is_int(&xfer.aToken[4], &size)
26702681
&& (blob_eq(&xfer.aToken[3],"-") || blob_is_hname(&xfer.aToken[3]))
26712682
){
26722683
--- src/xfer.c
+++ src/xfer.c
@@ -749,11 +749,11 @@
749 if( db_step(&q1)==SQLITE_ROW ){
750 sqlite3_int64 mtime = db_column_int64(&q1, 0);
751 const char *zHash = db_column_text(&q1, 1);
752 if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){
753 xfer_cannot_send_sha3_error(pXfer);
754 db_reset(&q1);
755 return;
756 }
757 if( isFull ){
758 /* If we have already reached the send size limit, send a (short)
759 ** uvigot card rather than a uvfile card. This only happens on the
@@ -2563,30 +2563,36 @@
2563 /* file HASH SIZE \n CONTENT
2564 ** file HASH DELTASRC SIZE \n CONTENT
2565 **
2566 ** Client receives a file transmitted from the server.
2567 */
2568 if( blob_eq(&xfer.aToken[0],"file") ){
 
 
2569 xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
2570 nArtifactRcvd++;
2571 }else
2572
2573 /* cfile HASH USIZE CSIZE \n CONTENT
2574 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
2575 **
2576 ** Client receives a compressed file transmitted from the server.
2577 */
2578 if( blob_eq(&xfer.aToken[0],"cfile") ){
 
 
2579 xfer_accept_compressed_file(&xfer, 0, 0);
2580 nArtifactRcvd++;
2581 }else
2582
2583 /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
2584 **
2585 ** Client accepts an unversioned file from the server.
2586 */
2587 if( blob_eq(&xfer.aToken[0], "uvfile") ){
 
 
2588 xfer_accept_unversioned_file(&xfer, 1);
2589 nArtifactRcvd++;
2590 nUvFileRcvd++;
2591 if( syncFlags & SYNC_VERBOSE ){
2592 fossil_print("\rUnversioned-file received: %s\n",
@@ -2633,14 +2639,18 @@
2633 ){
2634 int rid;
2635 int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1");
2636 rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
2637 if( rid>0 ){
2638 if( isPriv ){
2639 content_make_private(rid);
2640 }else{
2641 content_make_public(rid);
 
 
 
 
 
 
2642 }
2643 }else if( isPriv && !g.perm.Private ){
2644 /* ignore private files */
2645 }else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){
2646 rid = content_new(blob_str(&xfer.aToken[1]), isPriv);
@@ -2662,10 +2672,11 @@
2662 ** (indicating that the file has been deleted) and MTIME is newer,
2663 ** then do the deletion.
2664 */
2665 if( xfer.nToken==5
2666 && blob_eq(&xfer.aToken[0], "uvigot")
 
2667 && blob_is_filename(&xfer.aToken[1])
2668 && blob_is_int64(&xfer.aToken[2], &mtime)
2669 && blob_is_int(&xfer.aToken[4], &size)
2670 && (blob_eq(&xfer.aToken[3],"-") || blob_is_hname(&xfer.aToken[3]))
2671 ){
2672
--- src/xfer.c
+++ src/xfer.c
@@ -749,11 +749,11 @@
749 if( db_step(&q1)==SQLITE_ROW ){
750 sqlite3_int64 mtime = db_column_int64(&q1, 0);
751 const char *zHash = db_column_text(&q1, 1);
752 if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){
753 xfer_cannot_send_sha3_error(pXfer);
754 db_finalize(&q1);
755 return;
756 }
757 if( isFull ){
758 /* If we have already reached the send size limit, send a (short)
759 ** uvigot card rather than a uvfile card. This only happens on the
@@ -2563,30 +2563,36 @@
2563 /* file HASH SIZE \n CONTENT
2564 ** file HASH DELTASRC SIZE \n CONTENT
2565 **
2566 ** Client receives a file transmitted from the server.
2567 */
2568 if( blob_eq(&xfer.aToken[0],"file")
2569 && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0
2570 ){
2571 xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
2572 nArtifactRcvd++;
2573 }else
2574
2575 /* cfile HASH USIZE CSIZE \n CONTENT
2576 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
2577 **
2578 ** Client receives a compressed file transmitted from the server.
2579 */
2580 if( blob_eq(&xfer.aToken[0],"cfile")
2581 && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0
2582 ){
2583 xfer_accept_compressed_file(&xfer, 0, 0);
2584 nArtifactRcvd++;
2585 }else
2586
2587 /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
2588 **
2589 ** Client accepts an unversioned file from the server.
2590 */
2591 if( blob_eq(&xfer.aToken[0], "uvfile")
2592 && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0
2593 ){
2594 xfer_accept_unversioned_file(&xfer, 1);
2595 nArtifactRcvd++;
2596 nUvFileRcvd++;
2597 if( syncFlags & SYNC_VERBOSE ){
2598 fossil_print("\rUnversioned-file received: %s\n",
@@ -2633,14 +2639,18 @@
2639 ){
2640 int rid;
2641 int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1");
2642 rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
2643 if( rid>0 ){
2644 if( !isPriv ){
 
 
2645 content_make_public(rid);
2646 }else if( g.perm.Private
2647 || db_exists("SELECT 1 FROM phantom WHERE rid=%d", rid) ){
2648 /* Outside a sync of private content, only an artifact that is
2649 ** still a phantom here is marked, so that it is not asked for
2650 ** again. Content that this repository holds stays public. */
2651 content_make_private(rid);
2652 }
2653 }else if( isPriv && !g.perm.Private ){
2654 /* ignore private files */
2655 }else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){
2656 rid = content_new(blob_str(&xfer.aToken[1]), isPriv);
@@ -2662,10 +2672,11 @@
2672 ** (indicating that the file has been deleted) and MTIME is newer,
2673 ** then do the deletion.
2674 */
2675 if( xfer.nToken==5
2676 && blob_eq(&xfer.aToken[0], "uvigot")
2677 && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0
2678 && blob_is_filename(&xfer.aToken[1])
2679 && blob_is_int64(&xfer.aToken[2], &mtime)
2680 && blob_is_int(&xfer.aToken[4], &size)
2681 && (blob_eq(&xfer.aToken[3],"-") || blob_is_hname(&xfer.aToken[3]))
2682 ){
2683

Keyboard Shortcuts

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