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.
Commit
ffc8eb67a0d892c61872cc5400436991f2d0c3d9f3d36b5cbb3f9b3c44c9b0c8
Parent
2146def8af2115d…
17 files changed
+1
-1
+3
-2
+22
-2
+7
-2
+4
-1
+2
+1
-1
+1
-1
+12
-4
+2
-2
+3
-3
+1
-1
+16
-2
+1
-1
+10
-9
+18
-7
+18
-7
+1
-1
| --- src/dispatch.c | ||
| +++ src/dispatch.c | ||
| @@ -1120,11 +1120,11 @@ | ||
| 1120 | 1120 | blob_appendf(&buf, "boolean "); |
| 1121 | 1121 | } |
| 1122 | 1122 | blob_appendf(&buf,"setting"); |
| 1123 | 1123 | zDesc = blob_str(&buf); |
| 1124 | 1124 | } |
| 1125 | - if( memcmp(aCommand[i].zName, "test", 4)==0 ) continue; | |
| 1125 | + if( strncmp(aCommand[i].zName, "test", 4)==0 ) continue; | |
| 1126 | 1126 | if( occHelp[aCommand[i].iHelp] > 0 ){ |
| 1127 | 1127 | int j; |
| 1128 | 1128 | for(j=0; j<occHelp[aCommand[i].iHelp]; j++){ |
| 1129 | 1129 | unsigned int e = aCommand[bktHelp[aCommand[i].iHelp][j]].eCmdFlags; |
| 1130 | 1130 | if( e & CMDFLAG_1ST_TIER ){ |
| 1131 | 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( 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 @@ | ||
| 1827 | 1827 | if( zPwd[j]=='/' ){ |
| 1828 | 1828 | blob_append(pOut, "/..", 3); |
| 1829 | 1829 | } |
| 1830 | 1830 | } |
| 1831 | 1831 | while( i>0 && (zPwd[i]!='/')) --i; |
| 1832 | - blob_append(pOut, zPath+i, j-i); | |
| 1832 | + blob_append(pOut, zPath+i, -1); | |
| 1833 | 1833 | } |
| 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]!='/' ){ | |
| 1835 | 1836 | blob_append(pOut, "/", 1); |
| 1836 | 1837 | } |
| 1837 | 1838 | blob_reset(&tmp); |
| 1838 | 1839 | return; |
| 1839 | 1840 | } |
| 1840 | 1841 |
| --- 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 @@ | ||
| 942 | 942 | rec->aProps = 0; |
| 943 | 943 | rec->nProps = 0; |
| 944 | 944 | zLen = svn_find_header(*rec, "Prop-content-length"); |
| 945 | 945 | if( zLen ){ |
| 946 | 946 | nRawProps = atoi(zLen); |
| 947 | + if( nRawProps<0 ){ | |
| 948 | + fossil_fatal("svn-dump data format broken"); | |
| 949 | + } | |
| 947 | 950 | } |
| 948 | 951 | if( nRawProps ){ |
| 949 | 952 | int got; |
| 950 | 953 | char *zLine; |
| 954 | + char *zEnd; /* Start of the PROPS-END marker */ | |
| 951 | 955 | rec->pRawProps = pRawProps = fossil_malloc( nRawProps ); |
| 952 | 956 | got = fread(rec->pRawProps, 1, nRawProps, pIn); |
| 953 | 957 | if( got!=nRawProps ){ |
| 954 | 958 | fossil_fatal("short read: got %d of %d bytes", got, nRawProps); |
| 955 | 959 | } |
| 956 | - if( memcmp(&pRawProps[got-10], "PROPS-END\n", 10)!=0 ){ | |
| 960 | + if( got<10 || memcmp(&pRawProps[got-10], "PROPS-END\n", 10)!=0 ){ | |
| 957 | 961 | fossil_fatal("svn-dump data ended unexpectedly"); |
| 958 | 962 | } |
| 959 | 963 | zLine = pRawProps; |
| 960 | - while( zLine<(pRawProps+nRawProps-10) ){ | |
| 964 | + zEnd = pRawProps+nRawProps-10; | |
| 965 | + while( zLine<zEnd ){ | |
| 961 | 966 | char *eol; |
| 962 | 967 | int propLen; |
| 963 | 968 | if( zLine[0]=='D' ){ |
| 964 | 969 | propLen = atoi(&zLine[2]); |
| 965 | 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 | + } | |
| 966 | 974 | zLine = eol+1+propLen+1; |
| 967 | 975 | }else{ |
| 968 | 976 | if( zLine[0]!='K' ){ |
| 969 | 977 | fossil_fatal("svn-dump data format broken"); |
| 970 | 978 | } |
| 971 | 979 | propLen = atoi(&zLine[2]); |
| 972 | 980 | eol = strchr(zLine, '\n'); |
| 981 | + if( eol==0 || eol>=zEnd ){ | |
| 982 | + fossil_fatal("svn-dump data format broken"); | |
| 983 | + } | |
| 973 | 984 | zLine = eol+1; |
| 985 | + if( propLen<0 || propLen>=zEnd-zLine ){ | |
| 986 | + fossil_fatal("svn-dump data format broken"); | |
| 987 | + } | |
| 974 | 988 | eol = zLine+propLen; |
| 975 | 989 | if( *eol!='\n' ){ |
| 976 | 990 | fossil_fatal("svn-dump data format broken"); |
| 977 | 991 | } |
| 978 | 992 | *eol = 0; |
| @@ -984,11 +998,17 @@ | ||
| 984 | 998 | if( zLine[0]!='V' ){ |
| 985 | 999 | fossil_fatal("svn-dump data format broken"); |
| 986 | 1000 | } |
| 987 | 1001 | propLen = atoi(&zLine[2]); |
| 988 | 1002 | eol = strchr(zLine, '\n'); |
| 1003 | + if( eol==0 || eol>=zEnd ){ | |
| 1004 | + fossil_fatal("svn-dump data format broken"); | |
| 1005 | + } | |
| 989 | 1006 | zLine = eol+1; |
| 1007 | + if( propLen<0 || propLen>=zEnd-zLine ){ | |
| 1008 | + fossil_fatal("svn-dump data format broken"); | |
| 1009 | + } | |
| 990 | 1010 | eol = zLine+propLen; |
| 991 | 1011 | if( *eol!='\n' ){ |
| 992 | 1012 | fossil_fatal("svn-dump data format broken"); |
| 993 | 1013 | } |
| 994 | 1014 | *eol = 0; |
| 995 | 1015 |
| --- 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 @@ | ||
| 381 | 381 | ** Return NULL if there are no more tokens on the current line. |
| 382 | 382 | */ |
| 383 | 383 | static char *next_token(ManifestText *p, int *pLen){ |
| 384 | 384 | char *zStart; |
| 385 | 385 | int n; |
| 386 | - if( p->atEol ) return 0; | |
| 386 | + if( p->atEol ){ | |
| 387 | + if( pLen ) *pLen = 0; | |
| 388 | + return 0; | |
| 389 | + } | |
| 387 | 390 | zStart = p->z; |
| 388 | 391 | n = strcspn(p->z, " \n"); |
| 389 | 392 | p->atEol = p->z[n]=='\n'; |
| 390 | 393 | p->z[n] = 0; |
| 391 | 394 | p->z += n+1; |
| @@ -1035,11 +1038,13 @@ | ||
| 1035 | 1038 | if( size<oldsize ) SYNTAX("size overflow on W-card"); |
| 1036 | 1039 | oldsize = size; |
| 1037 | 1040 | } |
| 1038 | 1041 | if( p->zWiki!=0 ) SYNTAX("more than one W-card"); |
| 1039 | 1042 | 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 | + } | |
| 1041 | 1046 | p->zWiki = x.z; |
| 1042 | 1047 | x.z += size; |
| 1043 | 1048 | if( x.z[0]!='\n' ) SYNTAX("W-card content no \\n terminated"); |
| 1044 | 1049 | x.z[0] = 0; |
| 1045 | 1050 | x.z++; |
| 1046 | 1051 |
| --- 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 @@ | ||
| 2207 | 2207 | w = 0; |
| 2208 | 2208 | |
| 2209 | 2209 | if( i<size && (w = is_empty(data + i, size - i))==0 ){ |
| 2210 | 2210 | return 0; /* non-blank line after tag line */ |
| 2211 | 2211 | } |
| 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; | |
| 2213 | 2214 | } |
| 2214 | 2215 | |
| 2215 | 2216 | |
| 2216 | 2217 | /* parse_htmlblock -- parsing of inline HTML block */ |
| 2217 | 2218 | static size_t parse_htmlblock( |
| @@ -2242,10 +2243,11 @@ | ||
| 2242 | 2243 | i++; |
| 2243 | 2244 | if( i<size ){ |
| 2244 | 2245 | j = is_empty(data+i, size-i); |
| 2245 | 2246 | if( j ){ |
| 2246 | 2247 | work_size = i+j; |
| 2248 | + if( work_size>size ) work_size = size; | |
| 2247 | 2249 | if( !rndr->make.blockhtml ) return work_size; |
| 2248 | 2250 | blob_init(&work, data, work_size); |
| 2249 | 2251 | rndr->make.blockhtml(ob, &work, rndr->make.opaque); |
| 2250 | 2252 | return work_size; |
| 2251 | 2253 | } |
| @@ -2262,10 +2264,11 @@ | ||
| 2262 | 2264 | if( i+1<size ){ |
| 2263 | 2265 | i += 1; |
| 2264 | 2266 | j = is_empty(data+i, size-i); |
| 2265 | 2267 | if( j ){ |
| 2266 | 2268 | work_size = i+j; |
| 2269 | + if( work_size>size ) work_size = size; | |
| 2267 | 2270 | if( !rndr->make.blockhtml ) return work_size; |
| 2268 | 2271 | blob_init(&work, data, work_size); |
| 2269 | 2272 | rndr->make.blockhtml(ob, &work, rndr->make.opaque); |
| 2270 | 2273 | return work_size; |
| 2271 | 2274 | } |
| 2272 | 2275 |
| --- 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 |
+2
| --- src/markdown_html.c | ||
| +++ src/markdown_html.c | ||
| @@ -250,12 +250,14 @@ | ||
| 250 | 250 | z[j++] = fossil_tolower(z[i]); |
| 251 | 251 | }else if( fossil_isspace(z[i]) || z[i]=='-' || z[i]=='_' ){ |
| 252 | 252 | if( j>0 && z[j-1]!='-' ) z[j++] = '-'; |
| 253 | 253 | }else if( z[i]=='<' ){ |
| 254 | 254 | do{ i++; }while( z[i]!=0 && z[i]!='>' ); |
| 255 | + if( z[i]==0 ) break; | |
| 255 | 256 | }else if( z[i]=='&' ){ |
| 256 | 257 | do{ i++; }while( z[i]!=0 && z[i]!=';' ); |
| 258 | + if( z[i]==0 ) break; | |
| 257 | 259 | }else if( (z[i]&0x80)!=0 ){ |
| 258 | 260 | z[j++] = z[i]; |
| 259 | 261 | } |
| 260 | 262 | } |
| 261 | 263 | if( j>0 && z[j-1]=='-' ) j--; |
| 262 | 264 |
| --- 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 @@ | ||
| 728 | 728 | }else if( xtype==etDYNSTRING ){ |
| 729 | 729 | zExtra = bufpt; |
| 730 | 730 | }else if( xtype==etSTRINGID ){ |
| 731 | 731 | precision = hash_digits(flag_altform2); |
| 732 | 732 | } |
| 733 | + if( limit<0 || (precision>=0 && precision<limit) ) limit = precision; | |
| 733 | 734 | length = StrNLen32(bufpt, limit); |
| 734 | - if( precision>=0 && precision<length ) length = precision; | |
| 735 | 735 | break; |
| 736 | 736 | } |
| 737 | 737 | case etBLOB: { |
| 738 | 738 | int limit = flag_alternateform ? va_arg(ap, int) : -1; |
| 739 | 739 | Blob *pBlob = va_arg(ap, Blob*); |
| 740 | 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 | 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 @@ | ||
| 728 | 728 | }else if( xtype==etDYNSTRING ){ |
| 729 | 729 | zExtra = bufpt; |
| 730 | 730 | }else if( xtype==etSTRINGID ){ |
| 731 | 731 | precision = hash_digits(flag_altform2); |
| 732 | 732 | } |
| 733 | + if( limit<0 || (precision>=0 && precision<limit) ) limit = precision; | |
| 733 | 734 | length = StrNLen32(bufpt, limit); |
| 734 | - if( precision>=0 && precision<length ) length = precision; | |
| 735 | 735 | break; |
| 736 | 736 | } |
| 737 | 737 | case etBLOB: { |
| 738 | 738 | int limit = flag_alternateform ? va_arg(ap, int) : -1; |
| 739 | 739 | Blob *pBlob = va_arg(ap, Blob*); |
| 740 | 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 | 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 @@ | ||
| 465 | 465 | int rid = db_column_int(&s, 0); |
| 466 | 466 | int size = db_column_int(&s, 1); |
| 467 | 467 | if( size>=0 ){ |
| 468 | 468 | if( !bag_find(&bagDone, rid) ){ |
| 469 | 469 | 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 | + } | |
| 472 | 476 | } |
| 473 | 477 | }else{ |
| 474 | 478 | db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid); |
| 475 | 479 | rebuild_step_done(rid); |
| 476 | 480 | } |
| @@ -1527,12 +1531,16 @@ | ||
| 1527 | 1531 | int rid = db_column_int(&s, 0); |
| 1528 | 1532 | int size = db_column_int(&s, 1); |
| 1529 | 1533 | if( size>=0 ){ |
| 1530 | 1534 | if( !bag_find(&bagDone, rid) ){ |
| 1531 | 1535 | 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 | + } | |
| 1534 | 1542 | } |
| 1535 | 1543 | } |
| 1536 | 1544 | } |
| 1537 | 1545 | db_finalize(&s); |
| 1538 | 1546 | |
| 1539 | 1547 |
| --- 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 @@ | ||
| 210 | 210 | ** the connection to the repository database is opened. Set up the |
| 211 | 211 | ** database connection to be more useful to the human operator. |
| 212 | 212 | */ |
| 213 | 213 | static int sqlcmd_autoinit( |
| 214 | 214 | sqlite3 *db, |
| 215 | - const char **pzErrMsg, | |
| 216 | - const void *notUsed | |
| 215 | + char **pzErrMsg, | |
| 216 | + const sqlite3_api_routines *notUsed | |
| 217 | 217 | ){ |
| 218 | 218 | int mTrace = SQLITE_TRACE_CLOSE; |
| 219 | 219 | add_content_sql_commands(db); |
| 220 | 220 | db_add_aux_functions(db); |
| 221 | 221 | re_add_sql_func(db); |
| 222 | 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 | 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 @@ | ||
| 1605 | 1605 | void *p, |
| 1606 | 1606 | int argc, |
| 1607 | 1607 | const char **argv, |
| 1608 | 1608 | int *argl |
| 1609 | 1609 | ){ |
| 1610 | - if( argc!=4 || memcmp(argv[1],"link",5)!=0 ){ | |
| 1610 | + if( argc!=4 || strncmp(argv[1],"link",5)!=0 ){ | |
| 1611 | 1611 | return Th_WrongNumArgs(interp, "submenu link LABEL URL"); |
| 1612 | 1612 | } |
| 1613 | 1613 | if( argl[2]==0 ){ |
| 1614 | 1614 | Th_SetResult(interp, "link's LABEL is empty", -1); |
| 1615 | 1615 | return TH_ERROR; |
| @@ -2725,11 +2725,11 @@ | ||
| 2725 | 2725 | /* |
| 2726 | 2726 | ** Make sure that the TH1 script error was not caused by a "missing" |
| 2727 | 2727 | ** command hook handler as that is not actually an error condition. |
| 2728 | 2728 | */ |
| 2729 | 2729 | nResult = TH1_LEN(nResult); |
| 2730 | - if( memcmp(zResult, NO_COMMAND_HOOK_ERROR, nResult)!=0 ){ | |
| 2730 | + if( strncmp(zResult, NO_COMMAND_HOOK_ERROR, nResult)!=0 ){ | |
| 2731 | 2731 | sendError(0,zResult, nResult, 0); |
| 2732 | 2732 | }else{ |
| 2733 | 2733 | /* |
| 2734 | 2734 | ** There is no command hook handler "installed". This situation |
| 2735 | 2735 | ** is NOT actually an error. |
| @@ -2813,11 +2813,11 @@ | ||
| 2813 | 2813 | /* |
| 2814 | 2814 | ** Make sure that the TH1 script error was not caused by a "missing" |
| 2815 | 2815 | ** webpage hook handler as that is not actually an error condition. |
| 2816 | 2816 | */ |
| 2817 | 2817 | nResult = TH1_LEN(nResult); |
| 2818 | - if( memcmp(zResult, NO_WEBPAGE_HOOK_ERROR, nResult)!=0 ){ | |
| 2818 | + if( strncmp(zResult, NO_WEBPAGE_HOOK_ERROR, nResult)!=0 ){ | |
| 2819 | 2819 | sendError(0,zResult, nResult, 1); |
| 2820 | 2820 | }else{ |
| 2821 | 2821 | /* |
| 2822 | 2822 | ** There is no webpage hook handler "installed". This situation |
| 2823 | 2823 | ** is NOT actually an error. |
| 2824 | 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 || 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 @@ | ||
| 269 | 269 | const char *z = zTagList; |
| 270 | 270 | Blob links; |
| 271 | 271 | blob_zero(&links); |
| 272 | 272 | while( z && z[0] ){ |
| 273 | 273 | 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 ){ | |
| 275 | 275 | blob_appendf(&links, |
| 276 | 276 | "%z%#h</a>%.2s", |
| 277 | 277 | href("%R/timeline?r=%#t&c=%t",i,z,zDate), i,z, &z[i] |
| 278 | 278 | ); |
| 279 | 279 | }else{ |
| 280 | 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 || 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 @@ | ||
| 769 | 769 | if( zTempDirA ) fossil_path_free(zTempDirA); |
| 770 | 770 | #endif |
| 771 | 771 | return zTFile; |
| 772 | 772 | } |
| 773 | 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 | + | |
| 774 | 786 | /* |
| 775 | 787 | ** Turn memory limits for stack and heap on and off. The argument |
| 776 | 788 | ** is true to turn memory limits on and false to turn them off. |
| 777 | 789 | ** |
| 778 | 790 | ** Memory limits should be enabled at startup, but then turned off |
| 779 | 791 | ** before starting subprocesses. |
| 780 | 792 | */ |
| 781 | 793 | void fossil_limit_memory(int onOff){ |
| 782 | 794 | #if defined(__unix__) |
| 795 | +#if defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) | |
| 783 | 796 | static sqlite3_int64 origHeap = 10000000000LL; /* 10GB */ |
| 797 | +#endif | |
| 784 | 798 | static sqlite3_int64 origStack = 8000000 ; /* 8MB */ |
| 785 | 799 | struct rlimit x; |
| 786 | 800 | |
| 787 | -#if defined(RLIMIT_DATA) | |
| 801 | +#if defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) | |
| 788 | 802 | getrlimit(RLIMIT_DATA, &x); |
| 789 | 803 | if( onOff ){ |
| 790 | 804 | origHeap = x.rlim_cur; |
| 791 | 805 | if( sizeof(void*)<8 || sizeof(x.rlim_cur)<8 ){ |
| 792 | 806 | x.rlim_cur = 1000000000 ; /* 1GB on 32-bit systems */ |
| @@ -795,11 +809,11 @@ | ||
| 795 | 809 | } |
| 796 | 810 | }else{ |
| 797 | 811 | x.rlim_cur = origHeap; |
| 798 | 812 | } |
| 799 | 813 | setrlimit(RLIMIT_DATA, &x); |
| 800 | -#endif /* defined(RLIMIT_DATA) */ | |
| 814 | +#endif /* defined(RLIMIT_DATA) && !defined(FOSSIL_ASAN) */ | |
| 801 | 815 | #if defined(RLIMIT_STACK) |
| 802 | 816 | getrlimit(RLIMIT_STACK, &x); |
| 803 | 817 | if( onOff ){ |
| 804 | 818 | origStack = x.rlim_cur; |
| 805 | 819 | x.rlim_cur = 8000000; /* 8MB */ |
| 806 | 820 |
| --- 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 @@ | ||
| 417 | 417 | return 1; |
| 418 | 418 | } |
| 419 | 419 | if( zName[0]!='-' ) continue; |
| 420 | 420 | for(i=0; i<count(azTemp); i++){ |
| 421 | 421 | n = (int)strlen(azTemp[i]); |
| 422 | - if( memcmp(azTemp[i], zName+1, n) ) continue; | |
| 422 | + if( strncmp(azTemp[i], zName+1, n) ) continue; | |
| 423 | 423 | if( zName[n+1]==0 ) return 1; |
| 424 | 424 | if( zName[n+1]=='-' ){ |
| 425 | 425 | for(j=n+2; zName[j] && fossil_isdigit(zName[j]); j++){} |
| 426 | 426 | if( zName[j]==0 ) return 1; |
| 427 | 427 | } |
| 428 | 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( 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 @@ | ||
| 959 | 959 | i++; |
| 960 | 960 | zValue = &z[i]; |
| 961 | 961 | while( z[i] && z[i]!='\'' ){ i++; } |
| 962 | 962 | }else{ |
| 963 | 963 | zValue = &z[i]; |
| 964 | - while( !fossil_isspace(z[i]) && z[i]!='>' ){ | |
| 964 | + while( z[i] && !fossil_isspace(z[i]) && z[i]!='>' ){ | |
| 965 | 965 | if( z[i]=='\'' || z[i]=='"' ) attrOk = 0; |
| 966 | 966 | i++; |
| 967 | 967 | } |
| 968 | 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]; | |
| 969 | 974 | if( attrOk ){ |
| 970 | 975 | 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++; | |
| 979 | 980 | } |
| 980 | 981 | if( attrOk ){ |
| 981 | 982 | if( aAttribute[iACode].iMask ) seen |= aAttribute[iACode].iMask; |
| 982 | 983 | p->nAttr++; |
| 983 | 984 | } |
| 984 | 985 |
| --- 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 @@ | ||
| 749 | 749 | if( db_step(&q1)==SQLITE_ROW ){ |
| 750 | 750 | sqlite3_int64 mtime = db_column_int64(&q1, 0); |
| 751 | 751 | const char *zHash = db_column_text(&q1, 1); |
| 752 | 752 | if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){ |
| 753 | 753 | xfer_cannot_send_sha3_error(pXfer); |
| 754 | - db_reset(&q1); | |
| 754 | + db_finalize(&q1); | |
| 755 | 755 | return; |
| 756 | 756 | } |
| 757 | 757 | if( isFull ){ |
| 758 | 758 | /* If we have already reached the send size limit, send a (short) |
| 759 | 759 | ** uvigot card rather than a uvfile card. This only happens on the |
| @@ -2563,30 +2563,36 @@ | ||
| 2563 | 2563 | /* file HASH SIZE \n CONTENT |
| 2564 | 2564 | ** file HASH DELTASRC SIZE \n CONTENT |
| 2565 | 2565 | ** |
| 2566 | 2566 | ** Client receives a file transmitted from the server. |
| 2567 | 2567 | */ |
| 2568 | - if( blob_eq(&xfer.aToken[0],"file") ){ | |
| 2568 | + if( blob_eq(&xfer.aToken[0],"file") | |
| 2569 | + && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 | |
| 2570 | + ){ | |
| 2569 | 2571 | xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0); |
| 2570 | 2572 | nArtifactRcvd++; |
| 2571 | 2573 | }else |
| 2572 | 2574 | |
| 2573 | 2575 | /* cfile HASH USIZE CSIZE \n CONTENT |
| 2574 | 2576 | ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT |
| 2575 | 2577 | ** |
| 2576 | 2578 | ** Client receives a compressed file transmitted from the server. |
| 2577 | 2579 | */ |
| 2578 | - if( blob_eq(&xfer.aToken[0],"cfile") ){ | |
| 2580 | + if( blob_eq(&xfer.aToken[0],"cfile") | |
| 2581 | + && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 | |
| 2582 | + ){ | |
| 2579 | 2583 | xfer_accept_compressed_file(&xfer, 0, 0); |
| 2580 | 2584 | nArtifactRcvd++; |
| 2581 | 2585 | }else |
| 2582 | 2586 | |
| 2583 | 2587 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2584 | 2588 | ** |
| 2585 | 2589 | ** Client accepts an unversioned file from the server. |
| 2586 | 2590 | */ |
| 2587 | - if( blob_eq(&xfer.aToken[0], "uvfile") ){ | |
| 2591 | + if( blob_eq(&xfer.aToken[0], "uvfile") | |
| 2592 | + && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0 | |
| 2593 | + ){ | |
| 2588 | 2594 | xfer_accept_unversioned_file(&xfer, 1); |
| 2589 | 2595 | nArtifactRcvd++; |
| 2590 | 2596 | nUvFileRcvd++; |
| 2591 | 2597 | if( syncFlags & SYNC_VERBOSE ){ |
| 2592 | 2598 | fossil_print("\rUnversioned-file received: %s\n", |
| @@ -2633,14 +2639,18 @@ | ||
| 2633 | 2639 | ){ |
| 2634 | 2640 | int rid; |
| 2635 | 2641 | int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1"); |
| 2636 | 2642 | rid = rid_from_uuid(&xfer.aToken[1], 0, 0); |
| 2637 | 2643 | if( rid>0 ){ |
| 2638 | - if( isPriv ){ | |
| 2639 | - content_make_private(rid); | |
| 2640 | - }else{ | |
| 2644 | + if( !isPriv ){ | |
| 2641 | 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); | |
| 2642 | 2652 | } |
| 2643 | 2653 | }else if( isPriv && !g.perm.Private ){ |
| 2644 | 2654 | /* ignore private files */ |
| 2645 | 2655 | }else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){ |
| 2646 | 2656 | rid = content_new(blob_str(&xfer.aToken[1]), isPriv); |
| @@ -2662,10 +2672,11 @@ | ||
| 2662 | 2672 | ** (indicating that the file has been deleted) and MTIME is newer, |
| 2663 | 2673 | ** then do the deletion. |
| 2664 | 2674 | */ |
| 2665 | 2675 | if( xfer.nToken==5 |
| 2666 | 2676 | && blob_eq(&xfer.aToken[0], "uvigot") |
| 2677 | + && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0 | |
| 2667 | 2678 | && blob_is_filename(&xfer.aToken[1]) |
| 2668 | 2679 | && blob_is_int64(&xfer.aToken[2], &mtime) |
| 2669 | 2680 | && blob_is_int(&xfer.aToken[4], &size) |
| 2670 | 2681 | && (blob_eq(&xfer.aToken[3],"-") || blob_is_hname(&xfer.aToken[3])) |
| 2671 | 2682 | ){ |
| 2672 | 2683 |
| --- 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 @@ | ||
| 749 | 749 | if( db_step(&q1)==SQLITE_ROW ){ |
| 750 | 750 | sqlite3_int64 mtime = db_column_int64(&q1, 0); |
| 751 | 751 | const char *zHash = db_column_text(&q1, 1); |
| 752 | 752 | if( pXfer->remoteVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){ |
| 753 | 753 | xfer_cannot_send_sha3_error(pXfer); |
| 754 | - db_reset(&q1); | |
| 754 | + db_finalize(&q1); | |
| 755 | 755 | return; |
| 756 | 756 | } |
| 757 | 757 | if( isFull ){ |
| 758 | 758 | /* If we have already reached the send size limit, send a (short) |
| 759 | 759 | ** uvigot card rather than a uvfile card. This only happens on the |
| @@ -2563,30 +2563,36 @@ | ||
| 2563 | 2563 | /* file HASH SIZE \n CONTENT |
| 2564 | 2564 | ** file HASH DELTASRC SIZE \n CONTENT |
| 2565 | 2565 | ** |
| 2566 | 2566 | ** Client receives a file transmitted from the server. |
| 2567 | 2567 | */ |
| 2568 | - if( blob_eq(&xfer.aToken[0],"file") ){ | |
| 2568 | + if( blob_eq(&xfer.aToken[0],"file") | |
| 2569 | + && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 | |
| 2570 | + ){ | |
| 2569 | 2571 | xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0); |
| 2570 | 2572 | nArtifactRcvd++; |
| 2571 | 2573 | }else |
| 2572 | 2574 | |
| 2573 | 2575 | /* cfile HASH USIZE CSIZE \n CONTENT |
| 2574 | 2576 | ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT |
| 2575 | 2577 | ** |
| 2576 | 2578 | ** Client receives a compressed file transmitted from the server. |
| 2577 | 2579 | */ |
| 2578 | - if( blob_eq(&xfer.aToken[0],"cfile") ){ | |
| 2580 | + if( blob_eq(&xfer.aToken[0],"cfile") | |
| 2581 | + && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 | |
| 2582 | + ){ | |
| 2579 | 2583 | xfer_accept_compressed_file(&xfer, 0, 0); |
| 2580 | 2584 | nArtifactRcvd++; |
| 2581 | 2585 | }else |
| 2582 | 2586 | |
| 2583 | 2587 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2584 | 2588 | ** |
| 2585 | 2589 | ** Client accepts an unversioned file from the server. |
| 2586 | 2590 | */ |
| 2587 | - if( blob_eq(&xfer.aToken[0], "uvfile") ){ | |
| 2591 | + if( blob_eq(&xfer.aToken[0], "uvfile") | |
| 2592 | + && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0 | |
| 2593 | + ){ | |
| 2588 | 2594 | xfer_accept_unversioned_file(&xfer, 1); |
| 2589 | 2595 | nArtifactRcvd++; |
| 2590 | 2596 | nUvFileRcvd++; |
| 2591 | 2597 | if( syncFlags & SYNC_VERBOSE ){ |
| 2592 | 2598 | fossil_print("\rUnversioned-file received: %s\n", |
| @@ -2633,14 +2639,18 @@ | ||
| 2633 | 2639 | ){ |
| 2634 | 2640 | int rid; |
| 2635 | 2641 | int isPriv = xfer.nToken>=3 && blob_eq(&xfer.aToken[2],"1"); |
| 2636 | 2642 | rid = rid_from_uuid(&xfer.aToken[1], 0, 0); |
| 2637 | 2643 | if( rid>0 ){ |
| 2638 | - if( isPriv ){ | |
| 2639 | - content_make_private(rid); | |
| 2640 | - }else{ | |
| 2644 | + if( !isPriv ){ | |
| 2641 | 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); | |
| 2642 | 2652 | } |
| 2643 | 2653 | }else if( isPriv && !g.perm.Private ){ |
| 2644 | 2654 | /* ignore private files */ |
| 2645 | 2655 | }else if( (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 ){ |
| 2646 | 2656 | rid = content_new(blob_str(&xfer.aToken[1]), isPriv); |
| @@ -2662,10 +2672,11 @@ | ||
| 2662 | 2672 | ** (indicating that the file has been deleted) and MTIME is newer, |
| 2663 | 2673 | ** then do the deletion. |
| 2664 | 2674 | */ |
| 2665 | 2675 | if( xfer.nToken==5 |
| 2666 | 2676 | && blob_eq(&xfer.aToken[0], "uvigot") |
| 2677 | + && (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0 | |
| 2667 | 2678 | && blob_is_filename(&xfer.aToken[1]) |
| 2668 | 2679 | && blob_is_int64(&xfer.aToken[2], &mtime) |
| 2669 | 2680 | && blob_is_int(&xfer.aToken[4], &size) |
| 2670 | 2681 | && (blob_eq(&xfer.aToken[3],"-") || blob_is_hname(&xfer.aToken[3])) |
| 2671 | 2682 | ){ |
| 2672 | 2683 |
| --- 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 |