Fossil SCM
Merge small-fixes-2 into trunk. This brings twenty fixes, among them purge undo and scrub --private, bounds checks in the svn importer, the If-Modified-Since and SCGI parsers, TH1 arithmetic, and the sync client and server.
Commit
8b0dbb2f3e5fba184080fa442e1f78c6b2a60b5be54b217a0b191ec135988ca1
Parent
453940b95180409…
9 files changed
+4
-2
+5
+60
-25
+4
-5
+98
-5
+1
+17
-12
+76
-11
+76
-11
+4
-2
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -1335,11 +1335,12 @@ | ||
| 1335 | 1335 | nWrote = fossil_utf8_to_console(blob_buffer(pBlob), blob_size(pBlob), 0); |
| 1336 | 1336 | if( nWrote>=0 ) return nWrote; |
| 1337 | 1337 | fflush(stdout); |
| 1338 | 1338 | _setmode(_fileno(stdout), _O_BINARY); |
| 1339 | 1339 | #endif |
| 1340 | - nWrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), stdout); | |
| 1340 | + nWrote = blob_size(pBlob)>0 | |
| 1341 | + ? fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), stdout) : 0; | |
| 1341 | 1342 | #if defined(_WIN32) |
| 1342 | 1343 | fflush(stdout); |
| 1343 | 1344 | _setmode(_fileno(stdout), _O_TEXT); |
| 1344 | 1345 | #endif |
| 1345 | 1346 | }else{ |
| @@ -1356,11 +1357,12 @@ | ||
| 1356 | 1357 | fossil_fatal_recursive("unable to open file \"%s\" for writing", |
| 1357 | 1358 | zFilename); |
| 1358 | 1359 | return 0; |
| 1359 | 1360 | } |
| 1360 | 1361 | blob_is_init(pBlob); |
| 1361 | - nWrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out); | |
| 1362 | + nWrote = blob_size(pBlob)>0 | |
| 1363 | + ? fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out) : 0; | |
| 1362 | 1364 | fclose(out); |
| 1363 | 1365 | if( nWrote!=(int)blob_size(pBlob) ){ |
| 1364 | 1366 | fossil_fatal_recursive("short write: %d of %d bytes to %s", nWrote, |
| 1365 | 1367 | blob_size(pBlob), zFilename); |
| 1366 | 1368 | } |
| 1367 | 1369 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -1335,11 +1335,12 @@ | |
| 1335 | nWrote = fossil_utf8_to_console(blob_buffer(pBlob), blob_size(pBlob), 0); |
| 1336 | if( nWrote>=0 ) return nWrote; |
| 1337 | fflush(stdout); |
| 1338 | _setmode(_fileno(stdout), _O_BINARY); |
| 1339 | #endif |
| 1340 | nWrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), stdout); |
| 1341 | #if defined(_WIN32) |
| 1342 | fflush(stdout); |
| 1343 | _setmode(_fileno(stdout), _O_TEXT); |
| 1344 | #endif |
| 1345 | }else{ |
| @@ -1356,11 +1357,12 @@ | |
| 1356 | fossil_fatal_recursive("unable to open file \"%s\" for writing", |
| 1357 | zFilename); |
| 1358 | return 0; |
| 1359 | } |
| 1360 | blob_is_init(pBlob); |
| 1361 | nWrote = fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out); |
| 1362 | fclose(out); |
| 1363 | if( nWrote!=(int)blob_size(pBlob) ){ |
| 1364 | fossil_fatal_recursive("short write: %d of %d bytes to %s", nWrote, |
| 1365 | blob_size(pBlob), zFilename); |
| 1366 | } |
| 1367 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -1335,11 +1335,12 @@ | |
| 1335 | nWrote = fossil_utf8_to_console(blob_buffer(pBlob), blob_size(pBlob), 0); |
| 1336 | if( nWrote>=0 ) return nWrote; |
| 1337 | fflush(stdout); |
| 1338 | _setmode(_fileno(stdout), _O_BINARY); |
| 1339 | #endif |
| 1340 | nWrote = blob_size(pBlob)>0 |
| 1341 | ? fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), stdout) : 0; |
| 1342 | #if defined(_WIN32) |
| 1343 | fflush(stdout); |
| 1344 | _setmode(_fileno(stdout), _O_TEXT); |
| 1345 | #endif |
| 1346 | }else{ |
| @@ -1356,11 +1357,12 @@ | |
| 1357 | fossil_fatal_recursive("unable to open file \"%s\" for writing", |
| 1358 | zFilename); |
| 1359 | return 0; |
| 1360 | } |
| 1361 | blob_is_init(pBlob); |
| 1362 | nWrote = blob_size(pBlob)>0 |
| 1363 | ? fwrite(blob_buffer(pBlob), 1, blob_size(pBlob), out) : 0; |
| 1364 | fclose(out); |
| 1365 | if( nWrote!=(int)blob_size(pBlob) ){ |
| 1366 | fossil_fatal_recursive("short write: %d of %d bytes to %s", nWrote, |
| 1367 | blob_size(pBlob), zFilename); |
| 1368 | } |
| 1369 |
+5
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -2540,10 +2540,11 @@ | ||
| 2540 | 2540 | int nRead; |
| 2541 | 2541 | int c, n, m; |
| 2542 | 2542 | |
| 2543 | 2543 | assert( !g.httpUseSSL ); |
| 2544 | 2544 | while( (c = fgetc(g.httpIn))!=EOF && fossil_isdigit((char)c) ){ |
| 2545 | + if( nHdr>=100000000 ) malformed_request("SCGI header too long"); | |
| 2545 | 2546 | nHdr = nHdr*10 + (char)c - '0'; |
| 2546 | 2547 | } |
| 2547 | 2548 | if( nHdr<16 ) malformed_request("SCGI header too short"); |
| 2548 | 2549 | zToFree = zHdr = fossil_malloc(nHdr); |
| 2549 | 2550 | nRead = (int)fread(zHdr, 1, nHdr, g.httpIn); |
| @@ -2982,10 +2983,14 @@ | ||
| 2982 | 2983 | {"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
| 2983 | 2984 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 0}; |
| 2984 | 2985 | if( 7==sscanf(zDate, "%3[A-Za-z], %d %3[A-Za-z] %d %d:%d:%d", zIgnore, |
| 2985 | 2986 | &mday, zMonth, &year, &hour, &min, &sec)){ |
| 2986 | 2987 | if( year > 1900 ) year -= 1900; |
| 2988 | + if( year<70 || year>8099 || mday<1 || mday>31 | |
| 2989 | + || hour<0 || hour>23 || min<0 || min>59 || sec<0 || sec>60 ){ | |
| 2990 | + return 0; | |
| 2991 | + } | |
| 2987 | 2992 | for(mon=0; azMonths[mon]; mon++){ |
| 2988 | 2993 | if( !fossil_strncmp( azMonths[mon], zMonth, 3 )){ |
| 2989 | 2994 | int nDay; |
| 2990 | 2995 | int isLeapYr; |
| 2991 | 2996 | static int priorDays[] = |
| 2992 | 2997 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -2540,10 +2540,11 @@ | |
| 2540 | int nRead; |
| 2541 | int c, n, m; |
| 2542 | |
| 2543 | assert( !g.httpUseSSL ); |
| 2544 | while( (c = fgetc(g.httpIn))!=EOF && fossil_isdigit((char)c) ){ |
| 2545 | nHdr = nHdr*10 + (char)c - '0'; |
| 2546 | } |
| 2547 | if( nHdr<16 ) malformed_request("SCGI header too short"); |
| 2548 | zToFree = zHdr = fossil_malloc(nHdr); |
| 2549 | nRead = (int)fread(zHdr, 1, nHdr, g.httpIn); |
| @@ -2982,10 +2983,14 @@ | |
| 2982 | {"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
| 2983 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 0}; |
| 2984 | if( 7==sscanf(zDate, "%3[A-Za-z], %d %3[A-Za-z] %d %d:%d:%d", zIgnore, |
| 2985 | &mday, zMonth, &year, &hour, &min, &sec)){ |
| 2986 | if( year > 1900 ) year -= 1900; |
| 2987 | for(mon=0; azMonths[mon]; mon++){ |
| 2988 | if( !fossil_strncmp( azMonths[mon], zMonth, 3 )){ |
| 2989 | int nDay; |
| 2990 | int isLeapYr; |
| 2991 | static int priorDays[] = |
| 2992 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -2540,10 +2540,11 @@ | |
| 2540 | int nRead; |
| 2541 | int c, n, m; |
| 2542 | |
| 2543 | assert( !g.httpUseSSL ); |
| 2544 | while( (c = fgetc(g.httpIn))!=EOF && fossil_isdigit((char)c) ){ |
| 2545 | if( nHdr>=100000000 ) malformed_request("SCGI header too long"); |
| 2546 | nHdr = nHdr*10 + (char)c - '0'; |
| 2547 | } |
| 2548 | if( nHdr<16 ) malformed_request("SCGI header too short"); |
| 2549 | zToFree = zHdr = fossil_malloc(nHdr); |
| 2550 | nRead = (int)fread(zHdr, 1, nHdr, g.httpIn); |
| @@ -2982,10 +2983,14 @@ | |
| 2983 | {"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
| 2984 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", 0}; |
| 2985 | if( 7==sscanf(zDate, "%3[A-Za-z], %d %3[A-Za-z] %d %d:%d:%d", zIgnore, |
| 2986 | &mday, zMonth, &year, &hour, &min, &sec)){ |
| 2987 | if( year > 1900 ) year -= 1900; |
| 2988 | if( year<70 || year>8099 || mday<1 || mday>31 |
| 2989 | || hour<0 || hour>23 || min<0 || min>59 || sec<0 || sec>60 ){ |
| 2990 | return 0; |
| 2991 | } |
| 2992 | for(mon=0; azMonths[mon]; mon++){ |
| 2993 | if( !fossil_strncmp( azMonths[mon], zMonth, 3 )){ |
| 2994 | int nDay; |
| 2995 | int isLeapYr; |
| 2996 | static int priorDays[] = |
| 2997 |
+60
-25
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -105,11 +105,11 @@ | ||
| 105 | 105 | for(i=0; i<gg.nFile; i++){ |
| 106 | 106 | fossil_free(gg.aFile[i].zName); |
| 107 | 107 | fossil_free(gg.aFile[i].zUuid); |
| 108 | 108 | fossil_free(gg.aFile[i].zPrior); |
| 109 | 109 | } |
| 110 | - memset(gg.aFile, 0, gg.nFile*sizeof(gg.aFile[0])); | |
| 110 | + if( gg.nFile ) memset(gg.aFile, 0, gg.nFile*sizeof(gg.aFile[0])); | |
| 111 | 111 | gg.nFile = 0; |
| 112 | 112 | if( freeAll ){ |
| 113 | 113 | fossil_free(gg.zPrevBranch); |
| 114 | 114 | fossil_free(gg.zPrevCheckin); |
| 115 | 115 | fossil_free(gg.azMerge); |
| @@ -265,11 +265,11 @@ | ||
| 265 | 265 | char *aTCard[4]; /* Array of T cards for manifest */ |
| 266 | 266 | int nTCard = 0; /* Entries used in aTCard[] */ |
| 267 | 267 | Blob record, cksum; |
| 268 | 268 | |
| 269 | 269 | import_prior_files(); |
| 270 | - qsort(gg.aFile, gg.nFile, sizeof(gg.aFile[0]), mfile_cmp); | |
| 270 | + if( gg.nFile ) qsort(gg.aFile, gg.nFile, sizeof(gg.aFile[0]), mfile_cmp); | |
| 271 | 271 | blob_zero(&record); |
| 272 | 272 | blob_appendf(&record, "C %F\n", gg.zComment); |
| 273 | 273 | blob_appendf(&record, "D %s\n", gg.zDate); |
| 274 | 274 | if( !g.fQuiet ){ |
| 275 | 275 | fossil_print("%.10s\r", gg.zDate); |
| @@ -1224,72 +1224,107 @@ | ||
| 1224 | 1224 | } |
| 1225 | 1225 | db_reset(&getChanges); |
| 1226 | 1226 | db_finalize(&setRid); |
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | -static u64 svn_get_varint(const char **pz){ | |
| 1229 | +static u64 svn_get_varint(const char **pz, const char *zEnd){ | |
| 1230 | 1230 | unsigned int v = 0; |
| 1231 | 1231 | do{ |
| 1232 | + if( *pz>=zEnd ) fossil_fatal("Invalid svndiff0 format"); | |
| 1232 | 1233 | v = (v<<7) | ((*pz)[0]&0x7f); |
| 1233 | 1234 | }while( (*pz)++[0]&0x80 ); |
| 1234 | 1235 | return v; |
| 1235 | 1236 | } |
| 1236 | 1237 | |
| 1238 | +/* | |
| 1239 | +** Apply the svndiff0 delta in pDiff to pSrc and write the result into | |
| 1240 | +** pOut. Every offset and length is checked against the buffer it names | |
| 1241 | +** before it is used. | |
| 1242 | +*/ | |
| 1237 | 1243 | static void svn_apply_svndiff(Blob *pDiff, Blob *pSrc, Blob *pOut){ |
| 1238 | 1244 | const char *zDiff = blob_buffer(pDiff); |
| 1245 | + const char *zEnd = zDiff + blob_size(pDiff); | |
| 1246 | + u64 nSrc = blob_size(pSrc); | |
| 1239 | 1247 | char *zOut; |
| 1240 | 1248 | if( blob_size(pDiff)<4 || memcmp(zDiff, "SVN", 4)!=0 ){ |
| 1241 | 1249 | fossil_fatal("Invalid svndiff0 format"); |
| 1242 | 1250 | } |
| 1243 | 1251 | zDiff += 4; |
| 1244 | 1252 | blob_zero(pOut); |
| 1245 | - while( zDiff<(blob_buffer(pDiff)+blob_size(pDiff)) ){ | |
| 1246 | - u64 lenOut, lenInst, lenData, lenOld; | |
| 1253 | + while( zDiff<zEnd ){ | |
| 1254 | + u64 lenOut, lenInst, lenData, lenOld, lenLeft; | |
| 1247 | 1255 | const char *zInst; |
| 1248 | 1256 | const char *zData; |
| 1257 | + const char *zDataEnd; | |
| 1249 | 1258 | |
| 1250 | - u64 offSrc = svn_get_varint(&zDiff); | |
| 1251 | - /*lenSrc =*/ svn_get_varint(&zDiff); | |
| 1252 | - lenOut = svn_get_varint(&zDiff); | |
| 1253 | - lenInst = svn_get_varint(&zDiff); | |
| 1254 | - lenData = svn_get_varint(&zDiff); | |
| 1259 | + u64 offSrc = svn_get_varint(&zDiff, zEnd); | |
| 1260 | + /*lenSrc =*/ svn_get_varint(&zDiff, zEnd); | |
| 1261 | + lenOut = svn_get_varint(&zDiff, zEnd); | |
| 1262 | + lenInst = svn_get_varint(&zDiff, zEnd); | |
| 1263 | + lenData = svn_get_varint(&zDiff, zEnd); | |
| 1264 | + if( lenInst>(u64)(zEnd-zDiff) || lenData>(u64)(zEnd-zDiff)-lenInst ){ | |
| 1265 | + fossil_fatal("Invalid svndiff0 format"); | |
| 1266 | + } | |
| 1255 | 1267 | zInst = zDiff; |
| 1256 | 1268 | zData = zInst+lenInst; |
| 1269 | + zDataEnd = zData+lenData; | |
| 1257 | 1270 | lenOld = blob_size(pOut); |
| 1258 | 1271 | blob_resize(pOut, lenOut+lenOld); |
| 1259 | 1272 | zOut = blob_buffer(pOut)+lenOld; |
| 1273 | + lenLeft = lenOut; | |
| 1260 | 1274 | while( zDiff<zInst+lenInst ){ |
| 1261 | 1275 | u64 lenCpy = (*zDiff)&0x3f; |
| 1276 | + u64 off = 0; | |
| 1262 | 1277 | const char *zCpy; |
| 1263 | - switch( (*zDiff)&0xC0 ){ | |
| 1278 | + int op = (*zDiff)&0xC0; | |
| 1279 | + zDiff++; | |
| 1280 | + if( lenCpy==0 ){ | |
| 1281 | + lenCpy = svn_get_varint(&zDiff, zInst+lenInst); | |
| 1282 | + } | |
| 1283 | + if( op!=0x80 ){ | |
| 1284 | + off = svn_get_varint(&zDiff, zInst+lenInst); | |
| 1285 | + } | |
| 1286 | + if( lenCpy>lenLeft ){ | |
| 1287 | + fossil_fatal("Invalid svndiff0 format"); | |
| 1288 | + } | |
| 1289 | + switch( op ){ | |
| 1264 | 1290 | case 0x00: |
| 1265 | - if( 0==blob_size(pSrc) ){ | |
| 1291 | + if( 0==nSrc ){ | |
| 1266 | 1292 | /* https://fossil-scm.org/forum/forumpost/15d4b242bda2a108 */ |
| 1267 | 1293 | fossil_fatal("Don't know how to handle NULL input. " |
| 1268 | 1294 | "Tip: do not use the --incremental flag " |
| 1269 | 1295 | "in the svn dump command."); |
| 1270 | 1296 | } |
| 1271 | - zCpy = blob_buffer(pSrc)+offSrc; | |
| 1297 | + if( offSrc>nSrc || off>nSrc-offSrc || lenCpy>nSrc-offSrc-off ){ | |
| 1298 | + fossil_fatal("Invalid svndiff0 format"); | |
| 1299 | + } | |
| 1300 | + zCpy = blob_buffer(pSrc)+offSrc+off; | |
| 1301 | + break; | |
| 1302 | + case 0x40: | |
| 1303 | + if( lenCpy>0 && off>=(u64)(zOut-blob_buffer(pOut)) ){ | |
| 1304 | + fossil_fatal("Invalid svndiff0 format"); | |
| 1305 | + } | |
| 1306 | + zCpy = blob_buffer(pOut)+off; | |
| 1272 | 1307 | break; |
| 1273 | - case 0x40: zCpy = blob_buffer(pOut); break; | |
| 1274 | - case 0x80: zCpy = zData; break; | |
| 1308 | + case 0x80: | |
| 1309 | + if( lenCpy>(u64)(zDataEnd-zData) ){ | |
| 1310 | + fossil_fatal("Invalid svndiff0 format"); | |
| 1311 | + } | |
| 1312 | + zCpy = zData; | |
| 1313 | + zData += lenCpy; | |
| 1314 | + break; | |
| 1275 | 1315 | default: fossil_fatal("Invalid svndiff0 instruction"); |
| 1276 | 1316 | } |
| 1277 | - zDiff++; | |
| 1278 | - if( lenCpy==0 ){ | |
| 1279 | - lenCpy = svn_get_varint(&zDiff); | |
| 1280 | - } | |
| 1281 | - if( zCpy!=zData ){ | |
| 1282 | - zCpy += svn_get_varint(&zDiff); | |
| 1283 | - }else{ | |
| 1284 | - zData += lenCpy; | |
| 1285 | - } | |
| 1317 | + lenLeft -= lenCpy; | |
| 1286 | 1318 | while( lenCpy-- > 0 ){ |
| 1287 | 1319 | *zOut++ = *zCpy++; |
| 1288 | 1320 | } |
| 1289 | 1321 | } |
| 1290 | - zDiff += lenData; | |
| 1322 | + if( lenLeft!=0 ){ | |
| 1323 | + fossil_fatal("Invalid svndiff0 format"); | |
| 1324 | + } | |
| 1325 | + zDiff = zDataEnd; | |
| 1291 | 1326 | } |
| 1292 | 1327 | } |
| 1293 | 1328 | |
| 1294 | 1329 | /* |
| 1295 | 1330 | ** Extract the branch or tag that the given path is on. Return the branch ID. |
| 1296 | 1331 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -105,11 +105,11 @@ | |
| 105 | for(i=0; i<gg.nFile; i++){ |
| 106 | fossil_free(gg.aFile[i].zName); |
| 107 | fossil_free(gg.aFile[i].zUuid); |
| 108 | fossil_free(gg.aFile[i].zPrior); |
| 109 | } |
| 110 | memset(gg.aFile, 0, gg.nFile*sizeof(gg.aFile[0])); |
| 111 | gg.nFile = 0; |
| 112 | if( freeAll ){ |
| 113 | fossil_free(gg.zPrevBranch); |
| 114 | fossil_free(gg.zPrevCheckin); |
| 115 | fossil_free(gg.azMerge); |
| @@ -265,11 +265,11 @@ | |
| 265 | char *aTCard[4]; /* Array of T cards for manifest */ |
| 266 | int nTCard = 0; /* Entries used in aTCard[] */ |
| 267 | Blob record, cksum; |
| 268 | |
| 269 | import_prior_files(); |
| 270 | qsort(gg.aFile, gg.nFile, sizeof(gg.aFile[0]), mfile_cmp); |
| 271 | blob_zero(&record); |
| 272 | blob_appendf(&record, "C %F\n", gg.zComment); |
| 273 | blob_appendf(&record, "D %s\n", gg.zDate); |
| 274 | if( !g.fQuiet ){ |
| 275 | fossil_print("%.10s\r", gg.zDate); |
| @@ -1224,72 +1224,107 @@ | |
| 1224 | } |
| 1225 | db_reset(&getChanges); |
| 1226 | db_finalize(&setRid); |
| 1227 | } |
| 1228 | |
| 1229 | static u64 svn_get_varint(const char **pz){ |
| 1230 | unsigned int v = 0; |
| 1231 | do{ |
| 1232 | v = (v<<7) | ((*pz)[0]&0x7f); |
| 1233 | }while( (*pz)++[0]&0x80 ); |
| 1234 | return v; |
| 1235 | } |
| 1236 | |
| 1237 | static void svn_apply_svndiff(Blob *pDiff, Blob *pSrc, Blob *pOut){ |
| 1238 | const char *zDiff = blob_buffer(pDiff); |
| 1239 | char *zOut; |
| 1240 | if( blob_size(pDiff)<4 || memcmp(zDiff, "SVN", 4)!=0 ){ |
| 1241 | fossil_fatal("Invalid svndiff0 format"); |
| 1242 | } |
| 1243 | zDiff += 4; |
| 1244 | blob_zero(pOut); |
| 1245 | while( zDiff<(blob_buffer(pDiff)+blob_size(pDiff)) ){ |
| 1246 | u64 lenOut, lenInst, lenData, lenOld; |
| 1247 | const char *zInst; |
| 1248 | const char *zData; |
| 1249 | |
| 1250 | u64 offSrc = svn_get_varint(&zDiff); |
| 1251 | /*lenSrc =*/ svn_get_varint(&zDiff); |
| 1252 | lenOut = svn_get_varint(&zDiff); |
| 1253 | lenInst = svn_get_varint(&zDiff); |
| 1254 | lenData = svn_get_varint(&zDiff); |
| 1255 | zInst = zDiff; |
| 1256 | zData = zInst+lenInst; |
| 1257 | lenOld = blob_size(pOut); |
| 1258 | blob_resize(pOut, lenOut+lenOld); |
| 1259 | zOut = blob_buffer(pOut)+lenOld; |
| 1260 | while( zDiff<zInst+lenInst ){ |
| 1261 | u64 lenCpy = (*zDiff)&0x3f; |
| 1262 | const char *zCpy; |
| 1263 | switch( (*zDiff)&0xC0 ){ |
| 1264 | case 0x00: |
| 1265 | if( 0==blob_size(pSrc) ){ |
| 1266 | /* https://fossil-scm.org/forum/forumpost/15d4b242bda2a108 */ |
| 1267 | fossil_fatal("Don't know how to handle NULL input. " |
| 1268 | "Tip: do not use the --incremental flag " |
| 1269 | "in the svn dump command."); |
| 1270 | } |
| 1271 | zCpy = blob_buffer(pSrc)+offSrc; |
| 1272 | break; |
| 1273 | case 0x40: zCpy = blob_buffer(pOut); break; |
| 1274 | case 0x80: zCpy = zData; break; |
| 1275 | default: fossil_fatal("Invalid svndiff0 instruction"); |
| 1276 | } |
| 1277 | zDiff++; |
| 1278 | if( lenCpy==0 ){ |
| 1279 | lenCpy = svn_get_varint(&zDiff); |
| 1280 | } |
| 1281 | if( zCpy!=zData ){ |
| 1282 | zCpy += svn_get_varint(&zDiff); |
| 1283 | }else{ |
| 1284 | zData += lenCpy; |
| 1285 | } |
| 1286 | while( lenCpy-- > 0 ){ |
| 1287 | *zOut++ = *zCpy++; |
| 1288 | } |
| 1289 | } |
| 1290 | zDiff += lenData; |
| 1291 | } |
| 1292 | } |
| 1293 | |
| 1294 | /* |
| 1295 | ** Extract the branch or tag that the given path is on. Return the branch ID. |
| 1296 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -105,11 +105,11 @@ | |
| 105 | for(i=0; i<gg.nFile; i++){ |
| 106 | fossil_free(gg.aFile[i].zName); |
| 107 | fossil_free(gg.aFile[i].zUuid); |
| 108 | fossil_free(gg.aFile[i].zPrior); |
| 109 | } |
| 110 | if( gg.nFile ) memset(gg.aFile, 0, gg.nFile*sizeof(gg.aFile[0])); |
| 111 | gg.nFile = 0; |
| 112 | if( freeAll ){ |
| 113 | fossil_free(gg.zPrevBranch); |
| 114 | fossil_free(gg.zPrevCheckin); |
| 115 | fossil_free(gg.azMerge); |
| @@ -265,11 +265,11 @@ | |
| 265 | char *aTCard[4]; /* Array of T cards for manifest */ |
| 266 | int nTCard = 0; /* Entries used in aTCard[] */ |
| 267 | Blob record, cksum; |
| 268 | |
| 269 | import_prior_files(); |
| 270 | if( gg.nFile ) qsort(gg.aFile, gg.nFile, sizeof(gg.aFile[0]), mfile_cmp); |
| 271 | blob_zero(&record); |
| 272 | blob_appendf(&record, "C %F\n", gg.zComment); |
| 273 | blob_appendf(&record, "D %s\n", gg.zDate); |
| 274 | if( !g.fQuiet ){ |
| 275 | fossil_print("%.10s\r", gg.zDate); |
| @@ -1224,72 +1224,107 @@ | |
| 1224 | } |
| 1225 | db_reset(&getChanges); |
| 1226 | db_finalize(&setRid); |
| 1227 | } |
| 1228 | |
| 1229 | static u64 svn_get_varint(const char **pz, const char *zEnd){ |
| 1230 | unsigned int v = 0; |
| 1231 | do{ |
| 1232 | if( *pz>=zEnd ) fossil_fatal("Invalid svndiff0 format"); |
| 1233 | v = (v<<7) | ((*pz)[0]&0x7f); |
| 1234 | }while( (*pz)++[0]&0x80 ); |
| 1235 | return v; |
| 1236 | } |
| 1237 | |
| 1238 | /* |
| 1239 | ** Apply the svndiff0 delta in pDiff to pSrc and write the result into |
| 1240 | ** pOut. Every offset and length is checked against the buffer it names |
| 1241 | ** before it is used. |
| 1242 | */ |
| 1243 | static void svn_apply_svndiff(Blob *pDiff, Blob *pSrc, Blob *pOut){ |
| 1244 | const char *zDiff = blob_buffer(pDiff); |
| 1245 | const char *zEnd = zDiff + blob_size(pDiff); |
| 1246 | u64 nSrc = blob_size(pSrc); |
| 1247 | char *zOut; |
| 1248 | if( blob_size(pDiff)<4 || memcmp(zDiff, "SVN", 4)!=0 ){ |
| 1249 | fossil_fatal("Invalid svndiff0 format"); |
| 1250 | } |
| 1251 | zDiff += 4; |
| 1252 | blob_zero(pOut); |
| 1253 | while( zDiff<zEnd ){ |
| 1254 | u64 lenOut, lenInst, lenData, lenOld, lenLeft; |
| 1255 | const char *zInst; |
| 1256 | const char *zData; |
| 1257 | const char *zDataEnd; |
| 1258 | |
| 1259 | u64 offSrc = svn_get_varint(&zDiff, zEnd); |
| 1260 | /*lenSrc =*/ svn_get_varint(&zDiff, zEnd); |
| 1261 | lenOut = svn_get_varint(&zDiff, zEnd); |
| 1262 | lenInst = svn_get_varint(&zDiff, zEnd); |
| 1263 | lenData = svn_get_varint(&zDiff, zEnd); |
| 1264 | if( lenInst>(u64)(zEnd-zDiff) || lenData>(u64)(zEnd-zDiff)-lenInst ){ |
| 1265 | fossil_fatal("Invalid svndiff0 format"); |
| 1266 | } |
| 1267 | zInst = zDiff; |
| 1268 | zData = zInst+lenInst; |
| 1269 | zDataEnd = zData+lenData; |
| 1270 | lenOld = blob_size(pOut); |
| 1271 | blob_resize(pOut, lenOut+lenOld); |
| 1272 | zOut = blob_buffer(pOut)+lenOld; |
| 1273 | lenLeft = lenOut; |
| 1274 | while( zDiff<zInst+lenInst ){ |
| 1275 | u64 lenCpy = (*zDiff)&0x3f; |
| 1276 | u64 off = 0; |
| 1277 | const char *zCpy; |
| 1278 | int op = (*zDiff)&0xC0; |
| 1279 | zDiff++; |
| 1280 | if( lenCpy==0 ){ |
| 1281 | lenCpy = svn_get_varint(&zDiff, zInst+lenInst); |
| 1282 | } |
| 1283 | if( op!=0x80 ){ |
| 1284 | off = svn_get_varint(&zDiff, zInst+lenInst); |
| 1285 | } |
| 1286 | if( lenCpy>lenLeft ){ |
| 1287 | fossil_fatal("Invalid svndiff0 format"); |
| 1288 | } |
| 1289 | switch( op ){ |
| 1290 | case 0x00: |
| 1291 | if( 0==nSrc ){ |
| 1292 | /* https://fossil-scm.org/forum/forumpost/15d4b242bda2a108 */ |
| 1293 | fossil_fatal("Don't know how to handle NULL input. " |
| 1294 | "Tip: do not use the --incremental flag " |
| 1295 | "in the svn dump command."); |
| 1296 | } |
| 1297 | if( offSrc>nSrc || off>nSrc-offSrc || lenCpy>nSrc-offSrc-off ){ |
| 1298 | fossil_fatal("Invalid svndiff0 format"); |
| 1299 | } |
| 1300 | zCpy = blob_buffer(pSrc)+offSrc+off; |
| 1301 | break; |
| 1302 | case 0x40: |
| 1303 | if( lenCpy>0 && off>=(u64)(zOut-blob_buffer(pOut)) ){ |
| 1304 | fossil_fatal("Invalid svndiff0 format"); |
| 1305 | } |
| 1306 | zCpy = blob_buffer(pOut)+off; |
| 1307 | break; |
| 1308 | case 0x80: |
| 1309 | if( lenCpy>(u64)(zDataEnd-zData) ){ |
| 1310 | fossil_fatal("Invalid svndiff0 format"); |
| 1311 | } |
| 1312 | zCpy = zData; |
| 1313 | zData += lenCpy; |
| 1314 | break; |
| 1315 | default: fossil_fatal("Invalid svndiff0 instruction"); |
| 1316 | } |
| 1317 | lenLeft -= lenCpy; |
| 1318 | while( lenCpy-- > 0 ){ |
| 1319 | *zOut++ = *zCpy++; |
| 1320 | } |
| 1321 | } |
| 1322 | if( lenLeft!=0 ){ |
| 1323 | fossil_fatal("Invalid svndiff0 format"); |
| 1324 | } |
| 1325 | zDiff = zDataEnd; |
| 1326 | } |
| 1327 | } |
| 1328 | |
| 1329 | /* |
| 1330 | ** Extract the branch or tag that the given path is on. Return the branch ID. |
| 1331 |
+4
-5
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -2661,11 +2661,11 @@ | ||
| 2661 | 2661 | "Add attachment [/artifact/%!S|%h] to [/artifact/%!S|%h]", |
| 2662 | 2662 | p->zAttachSrc, p->zAttachName, |
| 2663 | 2663 | p->zAttachTarget, p->zAttachTarget); |
| 2664 | 2664 | }else{ |
| 2665 | 2665 | zComment = mprintf("Delete attachment \"%h\" from " |
| 2666 | - "[/artifact/%!S|%h", | |
| 2666 | + "[/artifact/%!S|%h]", | |
| 2667 | 2667 | p->zAttachName, p->zAttachTarget, |
| 2668 | 2668 | p->zAttachTarget); |
| 2669 | 2669 | } |
| 2670 | 2670 | break; |
| 2671 | 2671 | case CFTYPE_WIKI: |
| @@ -2687,14 +2687,13 @@ | ||
| 2687 | 2687 | "Add attachment [/artifact/%!S|%h] to tech note " |
| 2688 | 2688 | "[/technote/%!S|%S]", |
| 2689 | 2689 | p->zAttachSrc, p->zAttachName, p->zAttachTarget, p->zAttachTarget); |
| 2690 | 2690 | }else{ |
| 2691 | 2691 | zComment = mprintf( |
| 2692 | - "Delete attachment \"/artifact/%!S|%h\" from" | |
| 2692 | + "Delete attachment \"%h\" from" | |
| 2693 | 2693 | " tech note [/technote/%!S|%S]", |
| 2694 | - p->zAttachName, p->zAttachName, | |
| 2695 | - p->zAttachTarget,p->zAttachTarget); | |
| 2694 | + p->zAttachName, p->zAttachTarget, p->zAttachTarget); | |
| 2696 | 2695 | } |
| 2697 | 2696 | break; |
| 2698 | 2697 | case CFTYPE_TICKET: |
| 2699 | 2698 | attachToType = 't'; |
| 2700 | 2699 | if( isAdd ){ |
| @@ -2867,11 +2866,11 @@ | ||
| 2867 | 2866 | ); |
| 2868 | 2867 | /* |
| 2869 | 2868 | ** If this edit is the most recent, then make it the title for |
| 2870 | 2869 | ** all other entries for the same thread |
| 2871 | 2870 | */ |
| 2872 | - if( !db_exists("SELECT 1 FROM forumpost WHERE froot=%d AND firt=0" | |
| 2871 | + if( !db_exists("SELECT 1 FROM forumpost WHERE froot=%d AND firt IS NULL" | |
| 2873 | 2872 | " AND fpid!=%d AND fmtime>%.17g", froot, rid, p->rDate) |
| 2874 | 2873 | ){ |
| 2875 | 2874 | /* This entry establishes a new title for all entries on the thread */ |
| 2876 | 2875 | db_multi_exec( |
| 2877 | 2876 | "UPDATE event" |
| 2878 | 2877 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2661,11 +2661,11 @@ | |
| 2661 | "Add attachment [/artifact/%!S|%h] to [/artifact/%!S|%h]", |
| 2662 | p->zAttachSrc, p->zAttachName, |
| 2663 | p->zAttachTarget, p->zAttachTarget); |
| 2664 | }else{ |
| 2665 | zComment = mprintf("Delete attachment \"%h\" from " |
| 2666 | "[/artifact/%!S|%h", |
| 2667 | p->zAttachName, p->zAttachTarget, |
| 2668 | p->zAttachTarget); |
| 2669 | } |
| 2670 | break; |
| 2671 | case CFTYPE_WIKI: |
| @@ -2687,14 +2687,13 @@ | |
| 2687 | "Add attachment [/artifact/%!S|%h] to tech note " |
| 2688 | "[/technote/%!S|%S]", |
| 2689 | p->zAttachSrc, p->zAttachName, p->zAttachTarget, p->zAttachTarget); |
| 2690 | }else{ |
| 2691 | zComment = mprintf( |
| 2692 | "Delete attachment \"/artifact/%!S|%h\" from" |
| 2693 | " tech note [/technote/%!S|%S]", |
| 2694 | p->zAttachName, p->zAttachName, |
| 2695 | p->zAttachTarget,p->zAttachTarget); |
| 2696 | } |
| 2697 | break; |
| 2698 | case CFTYPE_TICKET: |
| 2699 | attachToType = 't'; |
| 2700 | if( isAdd ){ |
| @@ -2867,11 +2866,11 @@ | |
| 2867 | ); |
| 2868 | /* |
| 2869 | ** If this edit is the most recent, then make it the title for |
| 2870 | ** all other entries for the same thread |
| 2871 | */ |
| 2872 | if( !db_exists("SELECT 1 FROM forumpost WHERE froot=%d AND firt=0" |
| 2873 | " AND fpid!=%d AND fmtime>%.17g", froot, rid, p->rDate) |
| 2874 | ){ |
| 2875 | /* This entry establishes a new title for all entries on the thread */ |
| 2876 | db_multi_exec( |
| 2877 | "UPDATE event" |
| 2878 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -2661,11 +2661,11 @@ | |
| 2661 | "Add attachment [/artifact/%!S|%h] to [/artifact/%!S|%h]", |
| 2662 | p->zAttachSrc, p->zAttachName, |
| 2663 | p->zAttachTarget, p->zAttachTarget); |
| 2664 | }else{ |
| 2665 | zComment = mprintf("Delete attachment \"%h\" from " |
| 2666 | "[/artifact/%!S|%h]", |
| 2667 | p->zAttachName, p->zAttachTarget, |
| 2668 | p->zAttachTarget); |
| 2669 | } |
| 2670 | break; |
| 2671 | case CFTYPE_WIKI: |
| @@ -2687,14 +2687,13 @@ | |
| 2687 | "Add attachment [/artifact/%!S|%h] to tech note " |
| 2688 | "[/technote/%!S|%S]", |
| 2689 | p->zAttachSrc, p->zAttachName, p->zAttachTarget, p->zAttachTarget); |
| 2690 | }else{ |
| 2691 | zComment = mprintf( |
| 2692 | "Delete attachment \"%h\" from" |
| 2693 | " tech note [/technote/%!S|%S]", |
| 2694 | p->zAttachName, p->zAttachTarget, p->zAttachTarget); |
| 2695 | } |
| 2696 | break; |
| 2697 | case CFTYPE_TICKET: |
| 2698 | attachToType = 't'; |
| 2699 | if( isAdd ){ |
| @@ -2867,11 +2866,11 @@ | |
| 2866 | ); |
| 2867 | /* |
| 2868 | ** If this edit is the most recent, then make it the title for |
| 2869 | ** all other entries for the same thread |
| 2870 | */ |
| 2871 | if( !db_exists("SELECT 1 FROM forumpost WHERE froot=%d AND firt IS NULL" |
| 2872 | " AND fpid!=%d AND fmtime>%.17g", froot, rid, p->rDate) |
| 2873 | ){ |
| 2874 | /* This entry establishes a new title for all entries on the thread */ |
| 2875 | db_multi_exec( |
| 2876 | "UPDATE event" |
| 2877 |
+98
-5
| --- src/purge.c | ||
| +++ src/purge.c | ||
| @@ -401,19 +401,19 @@ | ||
| 401 | 401 | fossil_fatal("delta loop while uncompressing purged artifacts"); |
| 402 | 402 | } |
| 403 | 403 | bag_insert(&busy, iSrc); |
| 404 | 404 | } |
| 405 | 405 | db_prepare(&q, |
| 406 | - "SELECT uuid, data, isPrivate, ix.piid" | |
| 406 | + "SELECT uuid, data, isPrivate, ix.piid, orid" | |
| 407 | 407 | " FROM ix, purgeitem" |
| 408 | 408 | " WHERE ix.srcid=%d" |
| 409 | 409 | " AND ix.piid=purgeitem.piid;", |
| 410 | 410 | iSrc |
| 411 | 411 | ); |
| 412 | 412 | while( db_step(&q)==SQLITE_ROW ){ |
| 413 | 413 | Blob h1, c1, c2; |
| 414 | - int isPriv, rid; | |
| 414 | + int isPriv, rid, orid; | |
| 415 | 415 | blob_zero(&h1); |
| 416 | 416 | db_column_blob(&q, 0, &h1); |
| 417 | 417 | blob_zero(&c1); |
| 418 | 418 | db_column_blob(&q, 1, &c1); |
| 419 | 419 | blob_uncompress(&c1, &c1); |
| @@ -426,10 +426,26 @@ | ||
| 426 | 426 | } |
| 427 | 427 | if( hname_verify_hash(&c2, blob_buffer(&h1), blob_size(&h1))==0 ){ |
| 428 | 428 | fossil_fatal("incorrect hash on %b", &h1); |
| 429 | 429 | } |
| 430 | 430 | isPriv = db_column_int(&q, 2); |
| 431 | + orid = db_column_int(&q, 4); | |
| 432 | + if( orid>0 | |
| 433 | + && !db_exists("SELECT 1 FROM blob WHERE rid=%d OR uuid=%Q", | |
| 434 | + orid, blob_str(&h1)) | |
| 435 | + ){ | |
| 436 | + /* Restore it under its old record number, which links still name */ | |
| 437 | + db_multi_exec( | |
| 438 | + "INSERT INTO blob(rid,rcvid,size,uuid,content)" | |
| 439 | + " VALUES(%d,0,-1,%Q,NULL);" | |
| 440 | + "INSERT INTO phantom VALUES(%d);", | |
| 441 | + orid, blob_str(&h1), orid | |
| 442 | + ); | |
| 443 | + if( !isPriv ){ | |
| 444 | + db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d)", orid); | |
| 445 | + } | |
| 446 | + } | |
| 431 | 447 | rid = content_put_ex(&c2, blob_str(&h1), 0, 0, isPriv); |
| 432 | 448 | if( rid==0 ){ |
| 433 | 449 | fossil_fatal("%s", g.zErrMsg); |
| 434 | 450 | }else{ |
| 435 | 451 | if( !isPriv ) content_make_public(rid); |
| @@ -440,10 +456,47 @@ | ||
| 440 | 456 | blob_reset(&c2); |
| 441 | 457 | } |
| 442 | 458 | db_finalize(&q); |
| 443 | 459 | if( iSrc>0 ) bag_remove(&busy, iSrc); |
| 444 | 460 | } |
| 461 | + | |
| 462 | +/* | |
| 463 | +** Remove from the graveyard every artifact that was private when it was | |
| 464 | +** purged, and any purge event left empty, so that "fossil scrub" leaves | |
| 465 | +** no private content behind. An item that stays, but is stored as a | |
| 466 | +** delta from one that goes, is stored whole first. | |
| 467 | +*/ | |
| 468 | +void purge_drop_private_items(void){ | |
| 469 | + Stmt q; | |
| 470 | + if( !db_table_exists("repository","purgeitem") ) return; | |
| 471 | + db_multi_exec( | |
| 472 | + "CREATE TEMP TABLE pwhole AS" | |
| 473 | + " SELECT piid FROM purgeitem WHERE NOT isPrivate" | |
| 474 | + " AND srcid IN (SELECT piid FROM purgeitem WHERE isPrivate)" | |
| 475 | + ); | |
| 476 | + db_prepare(&q, "SELECT piid FROM pwhole"); | |
| 477 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 478 | + int piid = db_column_int(&q, 0); | |
| 479 | + Blob content, cmpr; | |
| 480 | + Stmt u; | |
| 481 | + purge_extract_item(piid, &content); | |
| 482 | + blob_compress(&content, &cmpr); | |
| 483 | + db_prepare(&u, "UPDATE purgeitem SET srcid=NULL, data=:data" | |
| 484 | + " WHERE piid=%d", piid); | |
| 485 | + db_bind_blob(&u, ":data", &cmpr); | |
| 486 | + db_exec(&u); | |
| 487 | + db_finalize(&u); | |
| 488 | + blob_reset(&content); | |
| 489 | + blob_reset(&cmpr); | |
| 490 | + } | |
| 491 | + db_finalize(&q); | |
| 492 | + db_multi_exec( | |
| 493 | + "DROP TABLE pwhole;" | |
| 494 | + "DELETE FROM purgeitem WHERE isPrivate;" | |
| 495 | + "DELETE FROM purgeevent WHERE peid NOT IN (SELECT peid FROM purgeitem);" | |
| 496 | + ); | |
| 497 | +} | |
| 445 | 498 | |
| 446 | 499 | /* |
| 447 | 500 | ** COMMAND: purge* |
| 448 | 501 | ** |
| 449 | 502 | ** The purge command removes content from a repository and stores that content |
| @@ -540,11 +593,11 @@ | ||
| 540 | 593 | Blob content; |
| 541 | 594 | if( g.argc<4 ) usage("cat HASH..."); |
| 542 | 595 | for(i=3; i<g.argc; i++){ |
| 543 | 596 | piid = db_int(0, "SELECT piid FROM purgeitem WHERE uuid LIKE '%q%%'", |
| 544 | 597 | g.argv[i]); |
| 545 | - if( piid==0 ) fossil_fatal("no such item: %s", g.argv[3]); | |
| 598 | + if( piid==0 ) fossil_fatal("no such item: %s", g.argv[i]); | |
| 546 | 599 | purge_extract_item(piid, &content); |
| 547 | 600 | blob_write_to_file(&content, "-"); |
| 548 | 601 | blob_reset(&content); |
| 549 | 602 | } |
| 550 | 603 | }else if( strncmp(zSubcmd, "checkins", n)==0 ){ |
| @@ -551,18 +604,26 @@ | ||
| 551 | 604 | int vid; |
| 552 | 605 | if( find_option("explain",0,0)!=0 || find_option("dry-run",0,0)!=0 ){ |
| 553 | 606 | purgeFlags |= PURGE_EXPLAIN_ONLY; |
| 554 | 607 | } |
| 555 | 608 | verify_all_options(); |
| 609 | + vid = 0; | |
| 610 | + if( g.localOpen ){ | |
| 611 | + vid = db_lget_int("checkout",0); | |
| 612 | + }else if( db_open_local(0) | |
| 613 | + && db_exists("SELECT 1 WHERE inode(%Q)=inode(%Q)", | |
| 614 | + g.zRepositoryName, db_repository_filename()) | |
| 615 | + ){ | |
| 616 | + vid = db_lget_int("checkout",0); | |
| 617 | + } | |
| 556 | 618 | db_begin_transaction(); |
| 557 | 619 | if( g.argc<=3 ) usage("checkins TAGS... [OPTIONS]"); |
| 558 | 620 | db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)"); |
| 559 | 621 | for(i=3; i<g.argc; i++){ |
| 560 | 622 | int r = name_to_typed_rid(g.argv[i], "br"); |
| 561 | 623 | compute_descendants(r, 1000000000); |
| 562 | 624 | } |
| 563 | - vid = db_lget_int("checkout",0); | |
| 564 | 625 | if( db_exists("SELECT 1 FROM ok WHERE rid=%d",vid) ){ |
| 565 | 626 | fossil_fatal("cannot purge the current check-out"); |
| 566 | 627 | } |
| 567 | 628 | find_checkin_associates("ok", 1); |
| 568 | 629 | purge_artifact_list("ok", "", purgeFlags); |
| @@ -610,11 +671,12 @@ | ||
| 610 | 671 | } |
| 611 | 672 | } |
| 612 | 673 | db_begin_transaction(); |
| 613 | 674 | for(i=3; i<g.argc; i++){ |
| 614 | 675 | int peid = atoi(g.argv[i]); |
| 615 | - if( !db_exists("SELECT 1 FROM purgeevent WHERE peid=%d",peid) ){ | |
| 676 | + if( !db_table_exists("repository","purgeevent") | |
| 677 | + || !db_exists("SELECT 1 FROM purgeevent WHERE peid=%d",peid) ){ | |
| 616 | 678 | fossil_fatal("no such purge event: %s", g.argv[i]); |
| 617 | 679 | } |
| 618 | 680 | db_multi_exec( |
| 619 | 681 | "DELETE FROM purgeevent WHERE peid=%d;" |
| 620 | 682 | "DELETE FROM purgeitem WHERE peid=%d;", |
| @@ -626,10 +688,14 @@ | ||
| 626 | 688 | fossil_fatal("not yet implemented...."); |
| 627 | 689 | }else if( strncmp(zSubcmd, "undo", n)==0 ){ |
| 628 | 690 | int peid; |
| 629 | 691 | if( g.argc!=4 ) usage("undo ID"); |
| 630 | 692 | peid = atoi(g.argv[3]); |
| 693 | + if( !db_table_exists("repository","purgeevent") | |
| 694 | + || !db_exists("SELECT 1 FROM purgeevent WHERE peid=%d",peid) ){ | |
| 695 | + fossil_fatal("no such purge event: %s", g.argv[3]); | |
| 696 | + } | |
| 631 | 697 | if( (purgeFlags & PURGE_EXPLAIN_ONLY)==0 ){ |
| 632 | 698 | db_begin_transaction(); |
| 633 | 699 | db_multi_exec( |
| 634 | 700 | "CREATE TEMP TABLE ix(" |
| 635 | 701 | " piid INTEGER PRIMARY KEY," |
| @@ -645,10 +711,37 @@ | ||
| 645 | 711 | " WHERE uuid IN (SELECT uuid FROM purgeitem WHERE peid=%d);", |
| 646 | 712 | peid |
| 647 | 713 | ); |
| 648 | 714 | manifest_crosslink_begin(); |
| 649 | 715 | purge_item_resurrect(0, 0); |
| 716 | + /* Relink check-ins whose purged parent is now restored */ | |
| 717 | + db_multi_exec( | |
| 718 | + "CREATE TEMP TABLE prelink AS" | |
| 719 | + " SELECT DISTINCT mid FROM mlink" | |
| 720 | + " WHERE pmid IN (SELECT blob.rid FROM blob, purgeitem" | |
| 721 | + " WHERE purgeitem.peid=%d" | |
| 722 | + " AND blob.uuid=purgeitem.uuid" | |
| 723 | + " AND blob.rid=purgeitem.orid)" | |
| 724 | + " AND NOT EXISTS(SELECT 1 FROM plink" | |
| 725 | + " WHERE cid=mlink.mid AND pid=mlink.pmid)", | |
| 726 | + peid | |
| 727 | + ); | |
| 728 | + db_prepare(&q, "SELECT mid FROM prelink"); | |
| 729 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 730 | + int mid = db_column_int(&q, 0); | |
| 731 | + Blob c; | |
| 732 | + if( content_get(mid, &c) ){ | |
| 733 | + db_multi_exec( | |
| 734 | + "DELETE FROM plink WHERE cid=%d;" | |
| 735 | + "DELETE FROM mlink WHERE mid=%d;", | |
| 736 | + mid, mid | |
| 737 | + ); | |
| 738 | + manifest_crosslink(mid, &c, MC_NO_ERRORS); | |
| 739 | + } | |
| 740 | + } | |
| 741 | + db_finalize(&q); | |
| 742 | + db_multi_exec("DROP TABLE prelink"); | |
| 650 | 743 | manifest_crosslink_end(0); |
| 651 | 744 | db_multi_exec("DELETE FROM purgeevent WHERE peid=%d", peid); |
| 652 | 745 | db_multi_exec("DELETE FROM purgeitem WHERE peid=%d", peid); |
| 653 | 746 | db_end_transaction(0); |
| 654 | 747 | } |
| 655 | 748 |
| --- src/purge.c | |
| +++ src/purge.c | |
| @@ -401,19 +401,19 @@ | |
| 401 | fossil_fatal("delta loop while uncompressing purged artifacts"); |
| 402 | } |
| 403 | bag_insert(&busy, iSrc); |
| 404 | } |
| 405 | db_prepare(&q, |
| 406 | "SELECT uuid, data, isPrivate, ix.piid" |
| 407 | " FROM ix, purgeitem" |
| 408 | " WHERE ix.srcid=%d" |
| 409 | " AND ix.piid=purgeitem.piid;", |
| 410 | iSrc |
| 411 | ); |
| 412 | while( db_step(&q)==SQLITE_ROW ){ |
| 413 | Blob h1, c1, c2; |
| 414 | int isPriv, rid; |
| 415 | blob_zero(&h1); |
| 416 | db_column_blob(&q, 0, &h1); |
| 417 | blob_zero(&c1); |
| 418 | db_column_blob(&q, 1, &c1); |
| 419 | blob_uncompress(&c1, &c1); |
| @@ -426,10 +426,26 @@ | |
| 426 | } |
| 427 | if( hname_verify_hash(&c2, blob_buffer(&h1), blob_size(&h1))==0 ){ |
| 428 | fossil_fatal("incorrect hash on %b", &h1); |
| 429 | } |
| 430 | isPriv = db_column_int(&q, 2); |
| 431 | rid = content_put_ex(&c2, blob_str(&h1), 0, 0, isPriv); |
| 432 | if( rid==0 ){ |
| 433 | fossil_fatal("%s", g.zErrMsg); |
| 434 | }else{ |
| 435 | if( !isPriv ) content_make_public(rid); |
| @@ -440,10 +456,47 @@ | |
| 440 | blob_reset(&c2); |
| 441 | } |
| 442 | db_finalize(&q); |
| 443 | if( iSrc>0 ) bag_remove(&busy, iSrc); |
| 444 | } |
| 445 | |
| 446 | /* |
| 447 | ** COMMAND: purge* |
| 448 | ** |
| 449 | ** The purge command removes content from a repository and stores that content |
| @@ -540,11 +593,11 @@ | |
| 540 | Blob content; |
| 541 | if( g.argc<4 ) usage("cat HASH..."); |
| 542 | for(i=3; i<g.argc; i++){ |
| 543 | piid = db_int(0, "SELECT piid FROM purgeitem WHERE uuid LIKE '%q%%'", |
| 544 | g.argv[i]); |
| 545 | if( piid==0 ) fossil_fatal("no such item: %s", g.argv[3]); |
| 546 | purge_extract_item(piid, &content); |
| 547 | blob_write_to_file(&content, "-"); |
| 548 | blob_reset(&content); |
| 549 | } |
| 550 | }else if( strncmp(zSubcmd, "checkins", n)==0 ){ |
| @@ -551,18 +604,26 @@ | |
| 551 | int vid; |
| 552 | if( find_option("explain",0,0)!=0 || find_option("dry-run",0,0)!=0 ){ |
| 553 | purgeFlags |= PURGE_EXPLAIN_ONLY; |
| 554 | } |
| 555 | verify_all_options(); |
| 556 | db_begin_transaction(); |
| 557 | if( g.argc<=3 ) usage("checkins TAGS... [OPTIONS]"); |
| 558 | db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)"); |
| 559 | for(i=3; i<g.argc; i++){ |
| 560 | int r = name_to_typed_rid(g.argv[i], "br"); |
| 561 | compute_descendants(r, 1000000000); |
| 562 | } |
| 563 | vid = db_lget_int("checkout",0); |
| 564 | if( db_exists("SELECT 1 FROM ok WHERE rid=%d",vid) ){ |
| 565 | fossil_fatal("cannot purge the current check-out"); |
| 566 | } |
| 567 | find_checkin_associates("ok", 1); |
| 568 | purge_artifact_list("ok", "", purgeFlags); |
| @@ -610,11 +671,12 @@ | |
| 610 | } |
| 611 | } |
| 612 | db_begin_transaction(); |
| 613 | for(i=3; i<g.argc; i++){ |
| 614 | int peid = atoi(g.argv[i]); |
| 615 | if( !db_exists("SELECT 1 FROM purgeevent WHERE peid=%d",peid) ){ |
| 616 | fossil_fatal("no such purge event: %s", g.argv[i]); |
| 617 | } |
| 618 | db_multi_exec( |
| 619 | "DELETE FROM purgeevent WHERE peid=%d;" |
| 620 | "DELETE FROM purgeitem WHERE peid=%d;", |
| @@ -626,10 +688,14 @@ | |
| 626 | fossil_fatal("not yet implemented...."); |
| 627 | }else if( strncmp(zSubcmd, "undo", n)==0 ){ |
| 628 | int peid; |
| 629 | if( g.argc!=4 ) usage("undo ID"); |
| 630 | peid = atoi(g.argv[3]); |
| 631 | if( (purgeFlags & PURGE_EXPLAIN_ONLY)==0 ){ |
| 632 | db_begin_transaction(); |
| 633 | db_multi_exec( |
| 634 | "CREATE TEMP TABLE ix(" |
| 635 | " piid INTEGER PRIMARY KEY," |
| @@ -645,10 +711,37 @@ | |
| 645 | " WHERE uuid IN (SELECT uuid FROM purgeitem WHERE peid=%d);", |
| 646 | peid |
| 647 | ); |
| 648 | manifest_crosslink_begin(); |
| 649 | purge_item_resurrect(0, 0); |
| 650 | manifest_crosslink_end(0); |
| 651 | db_multi_exec("DELETE FROM purgeevent WHERE peid=%d", peid); |
| 652 | db_multi_exec("DELETE FROM purgeitem WHERE peid=%d", peid); |
| 653 | db_end_transaction(0); |
| 654 | } |
| 655 |
| --- src/purge.c | |
| +++ src/purge.c | |
| @@ -401,19 +401,19 @@ | |
| 401 | fossil_fatal("delta loop while uncompressing purged artifacts"); |
| 402 | } |
| 403 | bag_insert(&busy, iSrc); |
| 404 | } |
| 405 | db_prepare(&q, |
| 406 | "SELECT uuid, data, isPrivate, ix.piid, orid" |
| 407 | " FROM ix, purgeitem" |
| 408 | " WHERE ix.srcid=%d" |
| 409 | " AND ix.piid=purgeitem.piid;", |
| 410 | iSrc |
| 411 | ); |
| 412 | while( db_step(&q)==SQLITE_ROW ){ |
| 413 | Blob h1, c1, c2; |
| 414 | int isPriv, rid, orid; |
| 415 | blob_zero(&h1); |
| 416 | db_column_blob(&q, 0, &h1); |
| 417 | blob_zero(&c1); |
| 418 | db_column_blob(&q, 1, &c1); |
| 419 | blob_uncompress(&c1, &c1); |
| @@ -426,10 +426,26 @@ | |
| 426 | } |
| 427 | if( hname_verify_hash(&c2, blob_buffer(&h1), blob_size(&h1))==0 ){ |
| 428 | fossil_fatal("incorrect hash on %b", &h1); |
| 429 | } |
| 430 | isPriv = db_column_int(&q, 2); |
| 431 | orid = db_column_int(&q, 4); |
| 432 | if( orid>0 |
| 433 | && !db_exists("SELECT 1 FROM blob WHERE rid=%d OR uuid=%Q", |
| 434 | orid, blob_str(&h1)) |
| 435 | ){ |
| 436 | /* Restore it under its old record number, which links still name */ |
| 437 | db_multi_exec( |
| 438 | "INSERT INTO blob(rid,rcvid,size,uuid,content)" |
| 439 | " VALUES(%d,0,-1,%Q,NULL);" |
| 440 | "INSERT INTO phantom VALUES(%d);", |
| 441 | orid, blob_str(&h1), orid |
| 442 | ); |
| 443 | if( !isPriv ){ |
| 444 | db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d)", orid); |
| 445 | } |
| 446 | } |
| 447 | rid = content_put_ex(&c2, blob_str(&h1), 0, 0, isPriv); |
| 448 | if( rid==0 ){ |
| 449 | fossil_fatal("%s", g.zErrMsg); |
| 450 | }else{ |
| 451 | if( !isPriv ) content_make_public(rid); |
| @@ -440,10 +456,47 @@ | |
| 456 | blob_reset(&c2); |
| 457 | } |
| 458 | db_finalize(&q); |
| 459 | if( iSrc>0 ) bag_remove(&busy, iSrc); |
| 460 | } |
| 461 | |
| 462 | /* |
| 463 | ** Remove from the graveyard every artifact that was private when it was |
| 464 | ** purged, and any purge event left empty, so that "fossil scrub" leaves |
| 465 | ** no private content behind. An item that stays, but is stored as a |
| 466 | ** delta from one that goes, is stored whole first. |
| 467 | */ |
| 468 | void purge_drop_private_items(void){ |
| 469 | Stmt q; |
| 470 | if( !db_table_exists("repository","purgeitem") ) return; |
| 471 | db_multi_exec( |
| 472 | "CREATE TEMP TABLE pwhole AS" |
| 473 | " SELECT piid FROM purgeitem WHERE NOT isPrivate" |
| 474 | " AND srcid IN (SELECT piid FROM purgeitem WHERE isPrivate)" |
| 475 | ); |
| 476 | db_prepare(&q, "SELECT piid FROM pwhole"); |
| 477 | while( db_step(&q)==SQLITE_ROW ){ |
| 478 | int piid = db_column_int(&q, 0); |
| 479 | Blob content, cmpr; |
| 480 | Stmt u; |
| 481 | purge_extract_item(piid, &content); |
| 482 | blob_compress(&content, &cmpr); |
| 483 | db_prepare(&u, "UPDATE purgeitem SET srcid=NULL, data=:data" |
| 484 | " WHERE piid=%d", piid); |
| 485 | db_bind_blob(&u, ":data", &cmpr); |
| 486 | db_exec(&u); |
| 487 | db_finalize(&u); |
| 488 | blob_reset(&content); |
| 489 | blob_reset(&cmpr); |
| 490 | } |
| 491 | db_finalize(&q); |
| 492 | db_multi_exec( |
| 493 | "DROP TABLE pwhole;" |
| 494 | "DELETE FROM purgeitem WHERE isPrivate;" |
| 495 | "DELETE FROM purgeevent WHERE peid NOT IN (SELECT peid FROM purgeitem);" |
| 496 | ); |
| 497 | } |
| 498 | |
| 499 | /* |
| 500 | ** COMMAND: purge* |
| 501 | ** |
| 502 | ** The purge command removes content from a repository and stores that content |
| @@ -540,11 +593,11 @@ | |
| 593 | Blob content; |
| 594 | if( g.argc<4 ) usage("cat HASH..."); |
| 595 | for(i=3; i<g.argc; i++){ |
| 596 | piid = db_int(0, "SELECT piid FROM purgeitem WHERE uuid LIKE '%q%%'", |
| 597 | g.argv[i]); |
| 598 | if( piid==0 ) fossil_fatal("no such item: %s", g.argv[i]); |
| 599 | purge_extract_item(piid, &content); |
| 600 | blob_write_to_file(&content, "-"); |
| 601 | blob_reset(&content); |
| 602 | } |
| 603 | }else if( strncmp(zSubcmd, "checkins", n)==0 ){ |
| @@ -551,18 +604,26 @@ | |
| 604 | int vid; |
| 605 | if( find_option("explain",0,0)!=0 || find_option("dry-run",0,0)!=0 ){ |
| 606 | purgeFlags |= PURGE_EXPLAIN_ONLY; |
| 607 | } |
| 608 | verify_all_options(); |
| 609 | vid = 0; |
| 610 | if( g.localOpen ){ |
| 611 | vid = db_lget_int("checkout",0); |
| 612 | }else if( db_open_local(0) |
| 613 | && db_exists("SELECT 1 WHERE inode(%Q)=inode(%Q)", |
| 614 | g.zRepositoryName, db_repository_filename()) |
| 615 | ){ |
| 616 | vid = db_lget_int("checkout",0); |
| 617 | } |
| 618 | db_begin_transaction(); |
| 619 | if( g.argc<=3 ) usage("checkins TAGS... [OPTIONS]"); |
| 620 | db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)"); |
| 621 | for(i=3; i<g.argc; i++){ |
| 622 | int r = name_to_typed_rid(g.argv[i], "br"); |
| 623 | compute_descendants(r, 1000000000); |
| 624 | } |
| 625 | if( db_exists("SELECT 1 FROM ok WHERE rid=%d",vid) ){ |
| 626 | fossil_fatal("cannot purge the current check-out"); |
| 627 | } |
| 628 | find_checkin_associates("ok", 1); |
| 629 | purge_artifact_list("ok", "", purgeFlags); |
| @@ -610,11 +671,12 @@ | |
| 671 | } |
| 672 | } |
| 673 | db_begin_transaction(); |
| 674 | for(i=3; i<g.argc; i++){ |
| 675 | int peid = atoi(g.argv[i]); |
| 676 | if( !db_table_exists("repository","purgeevent") |
| 677 | || !db_exists("SELECT 1 FROM purgeevent WHERE peid=%d",peid) ){ |
| 678 | fossil_fatal("no such purge event: %s", g.argv[i]); |
| 679 | } |
| 680 | db_multi_exec( |
| 681 | "DELETE FROM purgeevent WHERE peid=%d;" |
| 682 | "DELETE FROM purgeitem WHERE peid=%d;", |
| @@ -626,10 +688,14 @@ | |
| 688 | fossil_fatal("not yet implemented...."); |
| 689 | }else if( strncmp(zSubcmd, "undo", n)==0 ){ |
| 690 | int peid; |
| 691 | if( g.argc!=4 ) usage("undo ID"); |
| 692 | peid = atoi(g.argv[3]); |
| 693 | if( !db_table_exists("repository","purgeevent") |
| 694 | || !db_exists("SELECT 1 FROM purgeevent WHERE peid=%d",peid) ){ |
| 695 | fossil_fatal("no such purge event: %s", g.argv[3]); |
| 696 | } |
| 697 | if( (purgeFlags & PURGE_EXPLAIN_ONLY)==0 ){ |
| 698 | db_begin_transaction(); |
| 699 | db_multi_exec( |
| 700 | "CREATE TEMP TABLE ix(" |
| 701 | " piid INTEGER PRIMARY KEY," |
| @@ -645,10 +711,37 @@ | |
| 711 | " WHERE uuid IN (SELECT uuid FROM purgeitem WHERE peid=%d);", |
| 712 | peid |
| 713 | ); |
| 714 | manifest_crosslink_begin(); |
| 715 | purge_item_resurrect(0, 0); |
| 716 | /* Relink check-ins whose purged parent is now restored */ |
| 717 | db_multi_exec( |
| 718 | "CREATE TEMP TABLE prelink AS" |
| 719 | " SELECT DISTINCT mid FROM mlink" |
| 720 | " WHERE pmid IN (SELECT blob.rid FROM blob, purgeitem" |
| 721 | " WHERE purgeitem.peid=%d" |
| 722 | " AND blob.uuid=purgeitem.uuid" |
| 723 | " AND blob.rid=purgeitem.orid)" |
| 724 | " AND NOT EXISTS(SELECT 1 FROM plink" |
| 725 | " WHERE cid=mlink.mid AND pid=mlink.pmid)", |
| 726 | peid |
| 727 | ); |
| 728 | db_prepare(&q, "SELECT mid FROM prelink"); |
| 729 | while( db_step(&q)==SQLITE_ROW ){ |
| 730 | int mid = db_column_int(&q, 0); |
| 731 | Blob c; |
| 732 | if( content_get(mid, &c) ){ |
| 733 | db_multi_exec( |
| 734 | "DELETE FROM plink WHERE cid=%d;" |
| 735 | "DELETE FROM mlink WHERE mid=%d;", |
| 736 | mid, mid |
| 737 | ); |
| 738 | manifest_crosslink(mid, &c, MC_NO_ERRORS); |
| 739 | } |
| 740 | } |
| 741 | db_finalize(&q); |
| 742 | db_multi_exec("DROP TABLE prelink"); |
| 743 | manifest_crosslink_end(0); |
| 744 | db_multi_exec("DELETE FROM purgeevent WHERE peid=%d", peid); |
| 745 | db_multi_exec("DELETE FROM purgeitem WHERE peid=%d", peid); |
| 746 | db_end_transaction(0); |
| 747 | } |
| 748 |
+1
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -1058,10 +1058,11 @@ | ||
| 1058 | 1058 | } |
| 1059 | 1059 | db_begin_transaction(); |
| 1060 | 1060 | if( privateOnly || bVerily ){ |
| 1061 | 1061 | bNeedRebuild = db_exists("SELECT 1 FROM private"); |
| 1062 | 1062 | delete_private_content(); |
| 1063 | + purge_drop_private_items(); | |
| 1063 | 1064 | } |
| 1064 | 1065 | if( !privateOnly ){ |
| 1065 | 1066 | db_unprotect(PROTECT_ALL); |
| 1066 | 1067 | db_multi_exec( |
| 1067 | 1068 | "PRAGMA secure_delete=ON;" |
| 1068 | 1069 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -1058,10 +1058,11 @@ | |
| 1058 | } |
| 1059 | db_begin_transaction(); |
| 1060 | if( privateOnly || bVerily ){ |
| 1061 | bNeedRebuild = db_exists("SELECT 1 FROM private"); |
| 1062 | delete_private_content(); |
| 1063 | } |
| 1064 | if( !privateOnly ){ |
| 1065 | db_unprotect(PROTECT_ALL); |
| 1066 | db_multi_exec( |
| 1067 | "PRAGMA secure_delete=ON;" |
| 1068 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -1058,10 +1058,11 @@ | |
| 1058 | } |
| 1059 | db_begin_transaction(); |
| 1060 | if( privateOnly || bVerily ){ |
| 1061 | bNeedRebuild = db_exists("SELECT 1 FROM private"); |
| 1062 | delete_private_content(); |
| 1063 | purge_drop_private_items(); |
| 1064 | } |
| 1065 | if( !privateOnly ){ |
| 1066 | db_unprotect(PROTECT_ALL); |
| 1067 | db_multi_exec( |
| 1068 | "PRAGMA secure_delete=ON;" |
| 1069 |
M
src/th.c
+17
-12
| --- src/th.c | ||
| +++ src/th.c | ||
| @@ -947,11 +947,11 @@ | ||
| 947 | 947 | zInput += nSpace; |
| 948 | 948 | nInput -= nSpace; |
| 949 | 949 | zFirst = zInput; |
| 950 | 950 | |
| 951 | 951 | /* Check for a comment. If found, skip to the end of the line. */ |
| 952 | - if( zInput[0]=='#' ){ | |
| 952 | + if( nInput>0 && zInput[0]=='#' ){ | |
| 953 | 953 | while( !thEndOfLine(zInput, nInput) ){ |
| 954 | 954 | zInput++; |
| 955 | 955 | nInput--; |
| 956 | 956 | } |
| 957 | 957 | continue; |
| @@ -958,11 +958,11 @@ | ||
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | /* Gobble up input a word at a time until the end of the command |
| 961 | 961 | ** (a semi-colon or end of line). |
| 962 | 962 | */ |
| 963 | - while( rc==TH_OK && *zInput!=';' && !thEndOfLine(zInput, nInput) ){ | |
| 963 | + while( rc==TH_OK && !thEndOfLine(zInput, nInput) && *zInput!=';' ){ | |
| 964 | 964 | int nWord=0; |
| 965 | 965 | thNextSpace(interp, zInput, nInput, &nSpace); |
| 966 | 966 | rc = thNextWord(interp, &zInput[nSpace], nInput-nSpace, &nWord, 1); |
| 967 | 967 | zInput += (nSpace+nWord); |
| 968 | 968 | nInput -= (nSpace+nWord); |
| @@ -2166,31 +2166,33 @@ | ||
| 2166 | 2166 | } |
| 2167 | 2167 | } |
| 2168 | 2168 | } |
| 2169 | 2169 | |
| 2170 | 2170 | if( rc==TH_OK && eArgType==ARG_INTEGER ){ |
| 2171 | + unsigned int uLeft = (unsigned int)iLeft; | |
| 2172 | + unsigned int uRight = (unsigned int)iRight; | |
| 2171 | 2173 | int iRes = 0; |
| 2172 | 2174 | switch( pExpr->pOp->eOp ) { |
| 2173 | - case OP_MULTIPLY: iRes = iLeft*iRight; break; | |
| 2175 | + case OP_MULTIPLY: iRes = (int)(uLeft*uRight); break; | |
| 2174 | 2176 | case OP_DIVIDE: |
| 2175 | 2177 | if( !iRight ){ |
| 2176 | 2178 | Th_ErrorMessage(interp, "Divide by 0:", zLeft, nLeft); |
| 2177 | 2179 | rc = TH_ERROR; |
| 2178 | 2180 | goto finish; |
| 2179 | 2181 | } |
| 2180 | - iRes = iLeft/iRight; | |
| 2182 | + iRes = iRight==(-1) ? (int)(0u-uLeft) : iLeft/iRight; | |
| 2181 | 2183 | break; |
| 2182 | 2184 | case OP_MODULUS: |
| 2183 | 2185 | if( !iRight ){ |
| 2184 | 2186 | Th_ErrorMessage(interp, "Modulo by 0:", zLeft, nLeft); |
| 2185 | 2187 | rc = TH_ERROR; |
| 2186 | 2188 | goto finish; |
| 2187 | 2189 | } |
| 2188 | - iRes = iLeft%iRight; | |
| 2190 | + iRes = iRight==(-1) ? 0 : iLeft%iRight; | |
| 2189 | 2191 | break; |
| 2190 | - case OP_ADD: iRes = iLeft+iRight; break; | |
| 2191 | - case OP_SUBTRACT: iRes = iLeft-iRight; break; | |
| 2192 | + case OP_ADD: iRes = (int)(uLeft+uRight); break; | |
| 2193 | + case OP_SUBTRACT: iRes = (int)(uLeft-uRight); break; | |
| 2192 | 2194 | case OP_LEFTSHIFT: { |
| 2193 | 2195 | iRes = (int)(((unsigned int)iLeft)<<(iRight&0x1f)); |
| 2194 | 2196 | break; |
| 2195 | 2197 | } |
| 2196 | 2198 | case OP_RIGHTSHIFT: iRes = iLeft>>(iRight&0x1f); break; |
| @@ -2203,11 +2205,11 @@ | ||
| 2203 | 2205 | case OP_BITWISE_AND: iRes = iLeft&iRight; break; |
| 2204 | 2206 | case OP_BITWISE_XOR: iRes = iLeft^iRight; break; |
| 2205 | 2207 | case OP_BITWISE_OR: iRes = iLeft|iRight; break; |
| 2206 | 2208 | case OP_LOGICAL_AND: iRes = iLeft&&iRight; break; |
| 2207 | 2209 | case OP_LOGICAL_OR: iRes = iLeft||iRight; break; |
| 2208 | - case OP_UNARY_MINUS: iRes = -iLeft; break; | |
| 2210 | + case OP_UNARY_MINUS: iRes = (int)(0u-uLeft); break; | |
| 2209 | 2211 | case OP_UNARY_PLUS: iRes = +iLeft; break; |
| 2210 | 2212 | case OP_BITWISE_NOT: iRes = ~iLeft; break; |
| 2211 | 2213 | case OP_LOGICAL_NOT: iRes = !iLeft; break; |
| 2212 | 2214 | default: assert(!"Internal error"); |
| 2213 | 2215 | } |
| @@ -2822,14 +2824,17 @@ | ||
| 2822 | 2824 | ** If successful, store the result in *piOut and return TH_OK. |
| 2823 | 2825 | ** |
| 2824 | 2826 | ** If the string cannot be converted to an integer, return TH_ERROR. |
| 2825 | 2827 | ** If the interp argument is not NULL, leave an error message in the |
| 2826 | 2828 | ** interpreter result too. |
| 2829 | +** | |
| 2830 | +** A value too large for an int wraps around. The arithmetic is done on | |
| 2831 | +** an unsigned int, for which that is defined. | |
| 2827 | 2832 | */ |
| 2828 | 2833 | int Th_ToInt(Th_Interp *interp, const char *z, int n, int *piOut){ |
| 2829 | 2834 | int i = 0; |
| 2830 | - int iOut = 0; | |
| 2835 | + unsigned int iOut = 0; | |
| 2831 | 2836 | int base = 10; |
| 2832 | 2837 | int (*isdigit)(char) = th_isdigit; |
| 2833 | 2838 | |
| 2834 | 2839 | if( n<0 ){ |
| 2835 | 2840 | n = th_strlen(z); |
| @@ -2866,18 +2871,18 @@ | ||
| 2866 | 2871 | }else if( c>='A' ){ |
| 2867 | 2872 | c -= 'A'-10; |
| 2868 | 2873 | }else{ |
| 2869 | 2874 | c -= '0'; |
| 2870 | 2875 | } |
| 2871 | - iOut = iOut * base + c; | |
| 2876 | + iOut = iOut * (unsigned int)base + (unsigned int)c; | |
| 2872 | 2877 | } |
| 2873 | 2878 | |
| 2874 | 2879 | if( n>0 && z[0]=='-' ){ |
| 2875 | - iOut *= -1; | |
| 2880 | + iOut = 0u - iOut; | |
| 2876 | 2881 | } |
| 2877 | 2882 | |
| 2878 | - *piOut = iOut; | |
| 2883 | + *piOut = (int)iOut; | |
| 2879 | 2884 | return TH_OK; |
| 2880 | 2885 | } |
| 2881 | 2886 | |
| 2882 | 2887 | /* |
| 2883 | 2888 | ** Try to convert the string passed as arguments (z, n) to a double. |
| 2884 | 2889 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -947,11 +947,11 @@ | |
| 947 | zInput += nSpace; |
| 948 | nInput -= nSpace; |
| 949 | zFirst = zInput; |
| 950 | |
| 951 | /* Check for a comment. If found, skip to the end of the line. */ |
| 952 | if( zInput[0]=='#' ){ |
| 953 | while( !thEndOfLine(zInput, nInput) ){ |
| 954 | zInput++; |
| 955 | nInput--; |
| 956 | } |
| 957 | continue; |
| @@ -958,11 +958,11 @@ | |
| 958 | } |
| 959 | |
| 960 | /* Gobble up input a word at a time until the end of the command |
| 961 | ** (a semi-colon or end of line). |
| 962 | */ |
| 963 | while( rc==TH_OK && *zInput!=';' && !thEndOfLine(zInput, nInput) ){ |
| 964 | int nWord=0; |
| 965 | thNextSpace(interp, zInput, nInput, &nSpace); |
| 966 | rc = thNextWord(interp, &zInput[nSpace], nInput-nSpace, &nWord, 1); |
| 967 | zInput += (nSpace+nWord); |
| 968 | nInput -= (nSpace+nWord); |
| @@ -2166,31 +2166,33 @@ | |
| 2166 | } |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | if( rc==TH_OK && eArgType==ARG_INTEGER ){ |
| 2171 | int iRes = 0; |
| 2172 | switch( pExpr->pOp->eOp ) { |
| 2173 | case OP_MULTIPLY: iRes = iLeft*iRight; break; |
| 2174 | case OP_DIVIDE: |
| 2175 | if( !iRight ){ |
| 2176 | Th_ErrorMessage(interp, "Divide by 0:", zLeft, nLeft); |
| 2177 | rc = TH_ERROR; |
| 2178 | goto finish; |
| 2179 | } |
| 2180 | iRes = iLeft/iRight; |
| 2181 | break; |
| 2182 | case OP_MODULUS: |
| 2183 | if( !iRight ){ |
| 2184 | Th_ErrorMessage(interp, "Modulo by 0:", zLeft, nLeft); |
| 2185 | rc = TH_ERROR; |
| 2186 | goto finish; |
| 2187 | } |
| 2188 | iRes = iLeft%iRight; |
| 2189 | break; |
| 2190 | case OP_ADD: iRes = iLeft+iRight; break; |
| 2191 | case OP_SUBTRACT: iRes = iLeft-iRight; break; |
| 2192 | case OP_LEFTSHIFT: { |
| 2193 | iRes = (int)(((unsigned int)iLeft)<<(iRight&0x1f)); |
| 2194 | break; |
| 2195 | } |
| 2196 | case OP_RIGHTSHIFT: iRes = iLeft>>(iRight&0x1f); break; |
| @@ -2203,11 +2205,11 @@ | |
| 2203 | case OP_BITWISE_AND: iRes = iLeft&iRight; break; |
| 2204 | case OP_BITWISE_XOR: iRes = iLeft^iRight; break; |
| 2205 | case OP_BITWISE_OR: iRes = iLeft|iRight; break; |
| 2206 | case OP_LOGICAL_AND: iRes = iLeft&&iRight; break; |
| 2207 | case OP_LOGICAL_OR: iRes = iLeft||iRight; break; |
| 2208 | case OP_UNARY_MINUS: iRes = -iLeft; break; |
| 2209 | case OP_UNARY_PLUS: iRes = +iLeft; break; |
| 2210 | case OP_BITWISE_NOT: iRes = ~iLeft; break; |
| 2211 | case OP_LOGICAL_NOT: iRes = !iLeft; break; |
| 2212 | default: assert(!"Internal error"); |
| 2213 | } |
| @@ -2822,14 +2824,17 @@ | |
| 2822 | ** If successful, store the result in *piOut and return TH_OK. |
| 2823 | ** |
| 2824 | ** If the string cannot be converted to an integer, return TH_ERROR. |
| 2825 | ** If the interp argument is not NULL, leave an error message in the |
| 2826 | ** interpreter result too. |
| 2827 | */ |
| 2828 | int Th_ToInt(Th_Interp *interp, const char *z, int n, int *piOut){ |
| 2829 | int i = 0; |
| 2830 | int iOut = 0; |
| 2831 | int base = 10; |
| 2832 | int (*isdigit)(char) = th_isdigit; |
| 2833 | |
| 2834 | if( n<0 ){ |
| 2835 | n = th_strlen(z); |
| @@ -2866,18 +2871,18 @@ | |
| 2866 | }else if( c>='A' ){ |
| 2867 | c -= 'A'-10; |
| 2868 | }else{ |
| 2869 | c -= '0'; |
| 2870 | } |
| 2871 | iOut = iOut * base + c; |
| 2872 | } |
| 2873 | |
| 2874 | if( n>0 && z[0]=='-' ){ |
| 2875 | iOut *= -1; |
| 2876 | } |
| 2877 | |
| 2878 | *piOut = iOut; |
| 2879 | return TH_OK; |
| 2880 | } |
| 2881 | |
| 2882 | /* |
| 2883 | ** Try to convert the string passed as arguments (z, n) to a double. |
| 2884 |
| --- src/th.c | |
| +++ src/th.c | |
| @@ -947,11 +947,11 @@ | |
| 947 | zInput += nSpace; |
| 948 | nInput -= nSpace; |
| 949 | zFirst = zInput; |
| 950 | |
| 951 | /* Check for a comment. If found, skip to the end of the line. */ |
| 952 | if( nInput>0 && zInput[0]=='#' ){ |
| 953 | while( !thEndOfLine(zInput, nInput) ){ |
| 954 | zInput++; |
| 955 | nInput--; |
| 956 | } |
| 957 | continue; |
| @@ -958,11 +958,11 @@ | |
| 958 | } |
| 959 | |
| 960 | /* Gobble up input a word at a time until the end of the command |
| 961 | ** (a semi-colon or end of line). |
| 962 | */ |
| 963 | while( rc==TH_OK && !thEndOfLine(zInput, nInput) && *zInput!=';' ){ |
| 964 | int nWord=0; |
| 965 | thNextSpace(interp, zInput, nInput, &nSpace); |
| 966 | rc = thNextWord(interp, &zInput[nSpace], nInput-nSpace, &nWord, 1); |
| 967 | zInput += (nSpace+nWord); |
| 968 | nInput -= (nSpace+nWord); |
| @@ -2166,31 +2166,33 @@ | |
| 2166 | } |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | if( rc==TH_OK && eArgType==ARG_INTEGER ){ |
| 2171 | unsigned int uLeft = (unsigned int)iLeft; |
| 2172 | unsigned int uRight = (unsigned int)iRight; |
| 2173 | int iRes = 0; |
| 2174 | switch( pExpr->pOp->eOp ) { |
| 2175 | case OP_MULTIPLY: iRes = (int)(uLeft*uRight); break; |
| 2176 | case OP_DIVIDE: |
| 2177 | if( !iRight ){ |
| 2178 | Th_ErrorMessage(interp, "Divide by 0:", zLeft, nLeft); |
| 2179 | rc = TH_ERROR; |
| 2180 | goto finish; |
| 2181 | } |
| 2182 | iRes = iRight==(-1) ? (int)(0u-uLeft) : iLeft/iRight; |
| 2183 | break; |
| 2184 | case OP_MODULUS: |
| 2185 | if( !iRight ){ |
| 2186 | Th_ErrorMessage(interp, "Modulo by 0:", zLeft, nLeft); |
| 2187 | rc = TH_ERROR; |
| 2188 | goto finish; |
| 2189 | } |
| 2190 | iRes = iRight==(-1) ? 0 : iLeft%iRight; |
| 2191 | break; |
| 2192 | case OP_ADD: iRes = (int)(uLeft+uRight); break; |
| 2193 | case OP_SUBTRACT: iRes = (int)(uLeft-uRight); break; |
| 2194 | case OP_LEFTSHIFT: { |
| 2195 | iRes = (int)(((unsigned int)iLeft)<<(iRight&0x1f)); |
| 2196 | break; |
| 2197 | } |
| 2198 | case OP_RIGHTSHIFT: iRes = iLeft>>(iRight&0x1f); break; |
| @@ -2203,11 +2205,11 @@ | |
| 2205 | case OP_BITWISE_AND: iRes = iLeft&iRight; break; |
| 2206 | case OP_BITWISE_XOR: iRes = iLeft^iRight; break; |
| 2207 | case OP_BITWISE_OR: iRes = iLeft|iRight; break; |
| 2208 | case OP_LOGICAL_AND: iRes = iLeft&&iRight; break; |
| 2209 | case OP_LOGICAL_OR: iRes = iLeft||iRight; break; |
| 2210 | case OP_UNARY_MINUS: iRes = (int)(0u-uLeft); break; |
| 2211 | case OP_UNARY_PLUS: iRes = +iLeft; break; |
| 2212 | case OP_BITWISE_NOT: iRes = ~iLeft; break; |
| 2213 | case OP_LOGICAL_NOT: iRes = !iLeft; break; |
| 2214 | default: assert(!"Internal error"); |
| 2215 | } |
| @@ -2822,14 +2824,17 @@ | |
| 2824 | ** If successful, store the result in *piOut and return TH_OK. |
| 2825 | ** |
| 2826 | ** If the string cannot be converted to an integer, return TH_ERROR. |
| 2827 | ** If the interp argument is not NULL, leave an error message in the |
| 2828 | ** interpreter result too. |
| 2829 | ** |
| 2830 | ** A value too large for an int wraps around. The arithmetic is done on |
| 2831 | ** an unsigned int, for which that is defined. |
| 2832 | */ |
| 2833 | int Th_ToInt(Th_Interp *interp, const char *z, int n, int *piOut){ |
| 2834 | int i = 0; |
| 2835 | unsigned int iOut = 0; |
| 2836 | int base = 10; |
| 2837 | int (*isdigit)(char) = th_isdigit; |
| 2838 | |
| 2839 | if( n<0 ){ |
| 2840 | n = th_strlen(z); |
| @@ -2866,18 +2871,18 @@ | |
| 2871 | }else if( c>='A' ){ |
| 2872 | c -= 'A'-10; |
| 2873 | }else{ |
| 2874 | c -= '0'; |
| 2875 | } |
| 2876 | iOut = iOut * (unsigned int)base + (unsigned int)c; |
| 2877 | } |
| 2878 | |
| 2879 | if( n>0 && z[0]=='-' ){ |
| 2880 | iOut = 0u - iOut; |
| 2881 | } |
| 2882 | |
| 2883 | *piOut = (int)iOut; |
| 2884 | return TH_OK; |
| 2885 | } |
| 2886 | |
| 2887 | /* |
| 2888 | ** Try to convert the string passed as arguments (z, n) to a double. |
| 2889 |
+76
-11
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -256,16 +256,21 @@ | ||
| 256 | 256 | ** |
| 257 | 257 | ** The original size of the HASH artifact is USIZE. |
| 258 | 258 | ** |
| 259 | 259 | ** If any error occurs, write a message into pErr which has already |
| 260 | 260 | ** be initialized to an empty string. |
| 261 | +** | |
| 262 | +** Unless cloneFlag is set, the content must have the size USIZE and | |
| 263 | +** give the HASH, or it is refused. The hash of a delta is checked only | |
| 264 | +** if DELTASRC is at hand. A clone is not checked here. | |
| 261 | 265 | ** |
| 262 | 266 | ** Any artifact successfully received by this routine is considered to |
| 263 | 267 | ** be public and is therefore removed from the "private" table. |
| 264 | 268 | */ |
| 265 | 269 | static void xfer_accept_compressed_file( |
| 266 | 270 | Xfer *pXfer, |
| 271 | + int cloneFlag, | |
| 267 | 272 | char **pzUuidList, |
| 268 | 273 | int *pnUuidList |
| 269 | 274 | ){ |
| 270 | 275 | int szC; /* CSIZE */ |
| 271 | 276 | int szU; /* USIZE */ |
| @@ -299,20 +304,60 @@ | ||
| 299 | 304 | } |
| 300 | 305 | if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 301 | 306 | /* Ignore files that have been shunned */ |
| 302 | 307 | blob_reset(&content); |
| 303 | 308 | return; |
| 309 | + } | |
| 310 | + if( szU==0 | |
| 311 | + && (blob_size(&content)<=4 || blob_uncompress(&content, &content)) | |
| 312 | + ){ | |
| 313 | + blob_appendf(&pXfer->err, "malformed cfile content"); | |
| 314 | + blob_reset(&content); | |
| 315 | + return; | |
| 304 | 316 | } |
| 305 | 317 | if( pXfer->nToken==5 ){ |
| 306 | 318 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| 307 | 319 | pXfer->nDeltaRcvd++; |
| 308 | 320 | }else{ |
| 309 | 321 | srcid = 0; |
| 310 | 322 | pXfer->nFileRcvd++; |
| 323 | + } | |
| 324 | + if( !cloneFlag ){ | |
| 325 | + Blob *pUuid = &pXfer->aToken[1]; | |
| 326 | + Blob x; /* The content, uncompressed */ | |
| 327 | + Blob src, next; /* Source of a delta, and the delta applied to it */ | |
| 328 | + int ok = 1; | |
| 329 | + blob_zero(&x); | |
| 330 | + if( szU==0 ){ | |
| 331 | + blob_copy(&x, &content); | |
| 332 | + }else if( blob_size(&content)<=4 || blob_uncompress(&content, &x) ){ | |
| 333 | + blob_appendf(&pXfer->err, "malformed cfile content"); | |
| 334 | + blob_reset(&content); | |
| 335 | + return; | |
| 336 | + } | |
| 337 | + if( srcid==0 ){ | |
| 338 | + ok = (int)blob_size(&x)==szU | |
| 339 | + && hname_verify_hash(&x, blob_buffer(pUuid), blob_size(pUuid)); | |
| 340 | + }else if( delta_output_size(blob_buffer(&x), blob_size(&x))!=szU ){ | |
| 341 | + ok = 0; | |
| 342 | + }else if( content_get(srcid, &src) ){ | |
| 343 | + blob_zero(&next); | |
| 344 | + ok = blob_delta_apply(&src, &x, &next)>=0 | |
| 345 | + && hname_verify_hash(&next, blob_buffer(pUuid), blob_size(pUuid)); | |
| 346 | + blob_reset(&next); | |
| 347 | + blob_reset(&src); | |
| 348 | + } | |
| 349 | + blob_reset(&x); | |
| 350 | + if( !ok ){ | |
| 351 | + blob_appendf(&pXfer->err, | |
| 352 | + "wrong size or hash on received artifact: %b", pUuid); | |
| 353 | + blob_reset(&content); | |
| 354 | + return; | |
| 355 | + } | |
| 311 | 356 | } |
| 312 | 357 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, |
| 313 | - szC, isPriv); | |
| 358 | + szU, isPriv); | |
| 314 | 359 | Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]), |
| 315 | 360 | blob_size(&pXfer->aToken[1])); |
| 316 | 361 | remote_has(rid); |
| 317 | 362 | blob_reset(&content); |
| 318 | 363 | } |
| @@ -381,10 +426,13 @@ | ||
| 381 | 426 | goto end_accept_unversioned_file; |
| 382 | 427 | } |
| 383 | 428 | |
| 384 | 429 | /* Make sure we have a valid g.rcvid marker */ |
| 385 | 430 | content_rcvid_init(0); |
| 431 | + | |
| 432 | + /* The table might not exist yet if the other side sent no uv-hash pragma */ | |
| 433 | + unversioned_schema(); | |
| 386 | 434 | |
| 387 | 435 | /* Check to see if current content really should be overwritten. Ideally, |
| 388 | 436 | ** a uvfile card should never have been sent unless the overwrite should |
| 389 | 437 | ** occur. But do not trust the sender. Double-check. |
| 390 | 438 | */ |
| @@ -737,10 +785,11 @@ | ||
| 737 | 785 | int isClient /* True if sending from client to server */ |
| 738 | 786 | ){ |
| 739 | 787 | Stmt q1; |
| 740 | 788 | int isFull = !isClient && (int)blob_size(pXfer->pOut)>=pXfer->mxSend; |
| 741 | 789 | |
| 790 | + unversioned_schema(); | |
| 742 | 791 | if( isFull ) noContent = 1; |
| 743 | 792 | if( noContent ){ |
| 744 | 793 | db_prepare(&q1, |
| 745 | 794 | "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q", |
| 746 | 795 | zName |
| @@ -1415,11 +1464,11 @@ | ||
| 1415 | 1464 | cgi_reset_content(); |
| 1416 | 1465 | @ error not\sauthorized\sto\swrite%s(whyNotAuth()) |
| 1417 | 1466 | nErr++; |
| 1418 | 1467 | break; |
| 1419 | 1468 | } |
| 1420 | - xfer_accept_compressed_file(&xfer, pzUuidList, pnUuidList); | |
| 1469 | + xfer_accept_compressed_file(&xfer, 0, pzUuidList, pnUuidList); | |
| 1421 | 1470 | if( blob_size(&xfer.err) ){ |
| 1422 | 1471 | cgi_reset_content(); |
| 1423 | 1472 | @ error %T(blob_str(&xfer.err)) |
| 1424 | 1473 | nErr++; |
| 1425 | 1474 | break; |
| @@ -2097,10 +2146,22 @@ | ||
| 2097 | 2146 | ** Floating-point absolute value |
| 2098 | 2147 | */ |
| 2099 | 2148 | static double fossil_fabs(double x){ |
| 2100 | 2149 | return x>0.0 ? x : -x; |
| 2101 | 2150 | } |
| 2151 | + | |
| 2152 | +/* | |
| 2153 | +** Tell the user that unversioned content cannot be pushed because the | |
| 2154 | +** server has sent the "uv-pull-only" pragma. | |
| 2155 | +*/ | |
| 2156 | +static void uv_pull_only_warning(void){ | |
| 2157 | + fossil_warning( | |
| 2158 | + "Warning: uv-pull-only \n" | |
| 2159 | + " Unable to push unversioned content because you lack\n" | |
| 2160 | + " sufficient permission on the server\n" | |
| 2161 | + ); | |
| 2162 | +} | |
| 2102 | 2163 | |
| 2103 | 2164 | /* |
| 2104 | 2165 | ** Sync to the host identified in g.url.name and g.url.path. This |
| 2105 | 2166 | ** routine is called by the client. |
| 2106 | 2167 | ** |
| @@ -2176,14 +2237,13 @@ | ||
| 2176 | 2237 | const char *zPX; |
| 2177 | 2238 | configRcvMask = 0; |
| 2178 | 2239 | configSendMask = 0; |
| 2179 | 2240 | syncFlags &= ~(SYNC_PUSH); |
| 2180 | 2241 | zPX = db_get("parent-project-code", 0); |
| 2181 | - if( zPX==0 || db_get("parent-project-name",0)==0 ){ | |
| 2242 | + if( zPX==0 ){ | |
| 2182 | 2243 | fossil_fatal("there is no parent project: set the 'parent-project-code'" |
| 2183 | - " and 'parent-project-name' config parameters in order" | |
| 2184 | - " to pull from a parent project"); | |
| 2244 | + " config parameter in order to pull from a parent project"); | |
| 2185 | 2245 | } |
| 2186 | 2246 | if( zPX ){ |
| 2187 | 2247 | zAltPCode = zPX; |
| 2188 | 2248 | } |
| 2189 | 2249 | } |
| @@ -2584,11 +2644,11 @@ | ||
| 2584 | 2644 | ** Client receives a compressed file transmitted from the server. |
| 2585 | 2645 | */ |
| 2586 | 2646 | if( blob_eq(&xfer.aToken[0],"cfile") |
| 2587 | 2647 | && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 |
| 2588 | 2648 | ){ |
| 2589 | - xfer_accept_compressed_file(&xfer, 0, 0); | |
| 2649 | + xfer_accept_compressed_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0); | |
| 2590 | 2650 | nArtifactRcvd++; |
| 2591 | 2651 | }else |
| 2592 | 2652 | |
| 2593 | 2653 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2594 | 2654 | ** |
| @@ -2731,15 +2791,11 @@ | ||
| 2731 | 2791 | "UPDATE unversioned SET mtime=%lld WHERE name=%Q", mtime, zName |
| 2732 | 2792 | ); |
| 2733 | 2793 | db_unset("uv-hash", 0); |
| 2734 | 2794 | } |
| 2735 | 2795 | if( iStatus>=4 && uvPullOnly==1 ){ |
| 2736 | - fossil_warning( | |
| 2737 | - "Warning: uv-pull-only \n" | |
| 2738 | - " Unable to push unversioned content because you lack\n" | |
| 2739 | - " sufficient permission on the server\n" | |
| 2740 | - ); | |
| 2796 | + uv_pull_only_warning(); | |
| 2741 | 2797 | uvPullOnly = 2; |
| 2742 | 2798 | } |
| 2743 | 2799 | if( iStatus<=3 || uvPullOnly ){ |
| 2744 | 2800 | db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName); |
| 2745 | 2801 | }else if( iStatus==4 ){ |
| @@ -3039,10 +3095,19 @@ | ||
| 3039 | 3095 | } |
| 3040 | 3096 | } |
| 3041 | 3097 | nUncRcvd += blob_size(&recv); |
| 3042 | 3098 | blob_reset(&recv); |
| 3043 | 3099 | nCycle++; |
| 3100 | + | |
| 3101 | + /* Also warn for files that no uvigot card named */ | |
| 3102 | + if( uvPullOnly==1 && (syncFlags & SYNC_UV_REVERT)==0 | |
| 3103 | + && db_exists("SELECT 1 FROM uv_tosend") | |
| 3104 | + ){ | |
| 3105 | + uv_pull_only_warning(); | |
| 3106 | + uvPullOnly = 2; | |
| 3107 | + db_multi_exec("DELETE FROM uv_tosend"); | |
| 3108 | + } | |
| 3044 | 3109 | |
| 3045 | 3110 | /* Set go to 1 if we need to continue the sync/push/pull/clone for |
| 3046 | 3111 | ** another round. Set go to 0 if it is time to quit. */ |
| 3047 | 3112 | nFileRecv = xfer.nFileRcvd + xfer.nDeltaRcvd + xfer.nDanglingFile; |
| 3048 | 3113 | if( (nFileRecv>0 || newPhantom) && db_exists("SELECT 1 FROM phantom") ){ |
| 3049 | 3114 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -256,16 +256,21 @@ | |
| 256 | ** |
| 257 | ** The original size of the HASH artifact is USIZE. |
| 258 | ** |
| 259 | ** If any error occurs, write a message into pErr which has already |
| 260 | ** be initialized to an empty string. |
| 261 | ** |
| 262 | ** Any artifact successfully received by this routine is considered to |
| 263 | ** be public and is therefore removed from the "private" table. |
| 264 | */ |
| 265 | static void xfer_accept_compressed_file( |
| 266 | Xfer *pXfer, |
| 267 | char **pzUuidList, |
| 268 | int *pnUuidList |
| 269 | ){ |
| 270 | int szC; /* CSIZE */ |
| 271 | int szU; /* USIZE */ |
| @@ -299,20 +304,60 @@ | |
| 299 | } |
| 300 | if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 301 | /* Ignore files that have been shunned */ |
| 302 | blob_reset(&content); |
| 303 | return; |
| 304 | } |
| 305 | if( pXfer->nToken==5 ){ |
| 306 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| 307 | pXfer->nDeltaRcvd++; |
| 308 | }else{ |
| 309 | srcid = 0; |
| 310 | pXfer->nFileRcvd++; |
| 311 | } |
| 312 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, |
| 313 | szC, isPriv); |
| 314 | Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]), |
| 315 | blob_size(&pXfer->aToken[1])); |
| 316 | remote_has(rid); |
| 317 | blob_reset(&content); |
| 318 | } |
| @@ -381,10 +426,13 @@ | |
| 381 | goto end_accept_unversioned_file; |
| 382 | } |
| 383 | |
| 384 | /* Make sure we have a valid g.rcvid marker */ |
| 385 | content_rcvid_init(0); |
| 386 | |
| 387 | /* Check to see if current content really should be overwritten. Ideally, |
| 388 | ** a uvfile card should never have been sent unless the overwrite should |
| 389 | ** occur. But do not trust the sender. Double-check. |
| 390 | */ |
| @@ -737,10 +785,11 @@ | |
| 737 | int isClient /* True if sending from client to server */ |
| 738 | ){ |
| 739 | Stmt q1; |
| 740 | int isFull = !isClient && (int)blob_size(pXfer->pOut)>=pXfer->mxSend; |
| 741 | |
| 742 | if( isFull ) noContent = 1; |
| 743 | if( noContent ){ |
| 744 | db_prepare(&q1, |
| 745 | "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q", |
| 746 | zName |
| @@ -1415,11 +1464,11 @@ | |
| 1415 | cgi_reset_content(); |
| 1416 | @ error not\sauthorized\sto\swrite%s(whyNotAuth()) |
| 1417 | nErr++; |
| 1418 | break; |
| 1419 | } |
| 1420 | xfer_accept_compressed_file(&xfer, pzUuidList, pnUuidList); |
| 1421 | if( blob_size(&xfer.err) ){ |
| 1422 | cgi_reset_content(); |
| 1423 | @ error %T(blob_str(&xfer.err)) |
| 1424 | nErr++; |
| 1425 | break; |
| @@ -2097,10 +2146,22 @@ | |
| 2097 | ** Floating-point absolute value |
| 2098 | */ |
| 2099 | static double fossil_fabs(double x){ |
| 2100 | return x>0.0 ? x : -x; |
| 2101 | } |
| 2102 | |
| 2103 | /* |
| 2104 | ** Sync to the host identified in g.url.name and g.url.path. This |
| 2105 | ** routine is called by the client. |
| 2106 | ** |
| @@ -2176,14 +2237,13 @@ | |
| 2176 | const char *zPX; |
| 2177 | configRcvMask = 0; |
| 2178 | configSendMask = 0; |
| 2179 | syncFlags &= ~(SYNC_PUSH); |
| 2180 | zPX = db_get("parent-project-code", 0); |
| 2181 | if( zPX==0 || db_get("parent-project-name",0)==0 ){ |
| 2182 | fossil_fatal("there is no parent project: set the 'parent-project-code'" |
| 2183 | " and 'parent-project-name' config parameters in order" |
| 2184 | " to pull from a parent project"); |
| 2185 | } |
| 2186 | if( zPX ){ |
| 2187 | zAltPCode = zPX; |
| 2188 | } |
| 2189 | } |
| @@ -2584,11 +2644,11 @@ | |
| 2584 | ** Client receives a compressed file transmitted from the server. |
| 2585 | */ |
| 2586 | if( blob_eq(&xfer.aToken[0],"cfile") |
| 2587 | && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 |
| 2588 | ){ |
| 2589 | xfer_accept_compressed_file(&xfer, 0, 0); |
| 2590 | nArtifactRcvd++; |
| 2591 | }else |
| 2592 | |
| 2593 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2594 | ** |
| @@ -2731,15 +2791,11 @@ | |
| 2731 | "UPDATE unversioned SET mtime=%lld WHERE name=%Q", mtime, zName |
| 2732 | ); |
| 2733 | db_unset("uv-hash", 0); |
| 2734 | } |
| 2735 | if( iStatus>=4 && uvPullOnly==1 ){ |
| 2736 | fossil_warning( |
| 2737 | "Warning: uv-pull-only \n" |
| 2738 | " Unable to push unversioned content because you lack\n" |
| 2739 | " sufficient permission on the server\n" |
| 2740 | ); |
| 2741 | uvPullOnly = 2; |
| 2742 | } |
| 2743 | if( iStatus<=3 || uvPullOnly ){ |
| 2744 | db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName); |
| 2745 | }else if( iStatus==4 ){ |
| @@ -3039,10 +3095,19 @@ | |
| 3039 | } |
| 3040 | } |
| 3041 | nUncRcvd += blob_size(&recv); |
| 3042 | blob_reset(&recv); |
| 3043 | nCycle++; |
| 3044 | |
| 3045 | /* Set go to 1 if we need to continue the sync/push/pull/clone for |
| 3046 | ** another round. Set go to 0 if it is time to quit. */ |
| 3047 | nFileRecv = xfer.nFileRcvd + xfer.nDeltaRcvd + xfer.nDanglingFile; |
| 3048 | if( (nFileRecv>0 || newPhantom) && db_exists("SELECT 1 FROM phantom") ){ |
| 3049 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -256,16 +256,21 @@ | |
| 256 | ** |
| 257 | ** The original size of the HASH artifact is USIZE. |
| 258 | ** |
| 259 | ** If any error occurs, write a message into pErr which has already |
| 260 | ** be initialized to an empty string. |
| 261 | ** |
| 262 | ** Unless cloneFlag is set, the content must have the size USIZE and |
| 263 | ** give the HASH, or it is refused. The hash of a delta is checked only |
| 264 | ** if DELTASRC is at hand. A clone is not checked here. |
| 265 | ** |
| 266 | ** Any artifact successfully received by this routine is considered to |
| 267 | ** be public and is therefore removed from the "private" table. |
| 268 | */ |
| 269 | static void xfer_accept_compressed_file( |
| 270 | Xfer *pXfer, |
| 271 | int cloneFlag, |
| 272 | char **pzUuidList, |
| 273 | int *pnUuidList |
| 274 | ){ |
| 275 | int szC; /* CSIZE */ |
| 276 | int szU; /* USIZE */ |
| @@ -299,20 +304,60 @@ | |
| 304 | } |
| 305 | if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 306 | /* Ignore files that have been shunned */ |
| 307 | blob_reset(&content); |
| 308 | return; |
| 309 | } |
| 310 | if( szU==0 |
| 311 | && (blob_size(&content)<=4 || blob_uncompress(&content, &content)) |
| 312 | ){ |
| 313 | blob_appendf(&pXfer->err, "malformed cfile content"); |
| 314 | blob_reset(&content); |
| 315 | return; |
| 316 | } |
| 317 | if( pXfer->nToken==5 ){ |
| 318 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| 319 | pXfer->nDeltaRcvd++; |
| 320 | }else{ |
| 321 | srcid = 0; |
| 322 | pXfer->nFileRcvd++; |
| 323 | } |
| 324 | if( !cloneFlag ){ |
| 325 | Blob *pUuid = &pXfer->aToken[1]; |
| 326 | Blob x; /* The content, uncompressed */ |
| 327 | Blob src, next; /* Source of a delta, and the delta applied to it */ |
| 328 | int ok = 1; |
| 329 | blob_zero(&x); |
| 330 | if( szU==0 ){ |
| 331 | blob_copy(&x, &content); |
| 332 | }else if( blob_size(&content)<=4 || blob_uncompress(&content, &x) ){ |
| 333 | blob_appendf(&pXfer->err, "malformed cfile content"); |
| 334 | blob_reset(&content); |
| 335 | return; |
| 336 | } |
| 337 | if( srcid==0 ){ |
| 338 | ok = (int)blob_size(&x)==szU |
| 339 | && hname_verify_hash(&x, blob_buffer(pUuid), blob_size(pUuid)); |
| 340 | }else if( delta_output_size(blob_buffer(&x), blob_size(&x))!=szU ){ |
| 341 | ok = 0; |
| 342 | }else if( content_get(srcid, &src) ){ |
| 343 | blob_zero(&next); |
| 344 | ok = blob_delta_apply(&src, &x, &next)>=0 |
| 345 | && hname_verify_hash(&next, blob_buffer(pUuid), blob_size(pUuid)); |
| 346 | blob_reset(&next); |
| 347 | blob_reset(&src); |
| 348 | } |
| 349 | blob_reset(&x); |
| 350 | if( !ok ){ |
| 351 | blob_appendf(&pXfer->err, |
| 352 | "wrong size or hash on received artifact: %b", pUuid); |
| 353 | blob_reset(&content); |
| 354 | return; |
| 355 | } |
| 356 | } |
| 357 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, |
| 358 | szU, isPriv); |
| 359 | Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]), |
| 360 | blob_size(&pXfer->aToken[1])); |
| 361 | remote_has(rid); |
| 362 | blob_reset(&content); |
| 363 | } |
| @@ -381,10 +426,13 @@ | |
| 426 | goto end_accept_unversioned_file; |
| 427 | } |
| 428 | |
| 429 | /* Make sure we have a valid g.rcvid marker */ |
| 430 | content_rcvid_init(0); |
| 431 | |
| 432 | /* The table might not exist yet if the other side sent no uv-hash pragma */ |
| 433 | unversioned_schema(); |
| 434 | |
| 435 | /* Check to see if current content really should be overwritten. Ideally, |
| 436 | ** a uvfile card should never have been sent unless the overwrite should |
| 437 | ** occur. But do not trust the sender. Double-check. |
| 438 | */ |
| @@ -737,10 +785,11 @@ | |
| 785 | int isClient /* True if sending from client to server */ |
| 786 | ){ |
| 787 | Stmt q1; |
| 788 | int isFull = !isClient && (int)blob_size(pXfer->pOut)>=pXfer->mxSend; |
| 789 | |
| 790 | unversioned_schema(); |
| 791 | if( isFull ) noContent = 1; |
| 792 | if( noContent ){ |
| 793 | db_prepare(&q1, |
| 794 | "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q", |
| 795 | zName |
| @@ -1415,11 +1464,11 @@ | |
| 1464 | cgi_reset_content(); |
| 1465 | @ error not\sauthorized\sto\swrite%s(whyNotAuth()) |
| 1466 | nErr++; |
| 1467 | break; |
| 1468 | } |
| 1469 | xfer_accept_compressed_file(&xfer, 0, pzUuidList, pnUuidList); |
| 1470 | if( blob_size(&xfer.err) ){ |
| 1471 | cgi_reset_content(); |
| 1472 | @ error %T(blob_str(&xfer.err)) |
| 1473 | nErr++; |
| 1474 | break; |
| @@ -2097,10 +2146,22 @@ | |
| 2146 | ** Floating-point absolute value |
| 2147 | */ |
| 2148 | static double fossil_fabs(double x){ |
| 2149 | return x>0.0 ? x : -x; |
| 2150 | } |
| 2151 | |
| 2152 | /* |
| 2153 | ** Tell the user that unversioned content cannot be pushed because the |
| 2154 | ** server has sent the "uv-pull-only" pragma. |
| 2155 | */ |
| 2156 | static void uv_pull_only_warning(void){ |
| 2157 | fossil_warning( |
| 2158 | "Warning: uv-pull-only \n" |
| 2159 | " Unable to push unversioned content because you lack\n" |
| 2160 | " sufficient permission on the server\n" |
| 2161 | ); |
| 2162 | } |
| 2163 | |
| 2164 | /* |
| 2165 | ** Sync to the host identified in g.url.name and g.url.path. This |
| 2166 | ** routine is called by the client. |
| 2167 | ** |
| @@ -2176,14 +2237,13 @@ | |
| 2237 | const char *zPX; |
| 2238 | configRcvMask = 0; |
| 2239 | configSendMask = 0; |
| 2240 | syncFlags &= ~(SYNC_PUSH); |
| 2241 | zPX = db_get("parent-project-code", 0); |
| 2242 | if( zPX==0 ){ |
| 2243 | fossil_fatal("there is no parent project: set the 'parent-project-code'" |
| 2244 | " config parameter in order to pull from a parent project"); |
| 2245 | } |
| 2246 | if( zPX ){ |
| 2247 | zAltPCode = zPX; |
| 2248 | } |
| 2249 | } |
| @@ -2584,11 +2644,11 @@ | |
| 2644 | ** Client receives a compressed file transmitted from the server. |
| 2645 | */ |
| 2646 | if( blob_eq(&xfer.aToken[0],"cfile") |
| 2647 | && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 |
| 2648 | ){ |
| 2649 | xfer_accept_compressed_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0); |
| 2650 | nArtifactRcvd++; |
| 2651 | }else |
| 2652 | |
| 2653 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2654 | ** |
| @@ -2731,15 +2791,11 @@ | |
| 2791 | "UPDATE unversioned SET mtime=%lld WHERE name=%Q", mtime, zName |
| 2792 | ); |
| 2793 | db_unset("uv-hash", 0); |
| 2794 | } |
| 2795 | if( iStatus>=4 && uvPullOnly==1 ){ |
| 2796 | uv_pull_only_warning(); |
| 2797 | uvPullOnly = 2; |
| 2798 | } |
| 2799 | if( iStatus<=3 || uvPullOnly ){ |
| 2800 | db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName); |
| 2801 | }else if( iStatus==4 ){ |
| @@ -3039,10 +3095,19 @@ | |
| 3095 | } |
| 3096 | } |
| 3097 | nUncRcvd += blob_size(&recv); |
| 3098 | blob_reset(&recv); |
| 3099 | nCycle++; |
| 3100 | |
| 3101 | /* Also warn for files that no uvigot card named */ |
| 3102 | if( uvPullOnly==1 && (syncFlags & SYNC_UV_REVERT)==0 |
| 3103 | && db_exists("SELECT 1 FROM uv_tosend") |
| 3104 | ){ |
| 3105 | uv_pull_only_warning(); |
| 3106 | uvPullOnly = 2; |
| 3107 | db_multi_exec("DELETE FROM uv_tosend"); |
| 3108 | } |
| 3109 | |
| 3110 | /* Set go to 1 if we need to continue the sync/push/pull/clone for |
| 3111 | ** another round. Set go to 0 if it is time to quit. */ |
| 3112 | nFileRecv = xfer.nFileRcvd + xfer.nDeltaRcvd + xfer.nDanglingFile; |
| 3113 | if( (nFileRecv>0 || newPhantom) && db_exists("SELECT 1 FROM phantom") ){ |
| 3114 |
+76
-11
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -256,16 +256,21 @@ | ||
| 256 | 256 | ** |
| 257 | 257 | ** The original size of the HASH artifact is USIZE. |
| 258 | 258 | ** |
| 259 | 259 | ** If any error occurs, write a message into pErr which has already |
| 260 | 260 | ** be initialized to an empty string. |
| 261 | +** | |
| 262 | +** Unless cloneFlag is set, the content must have the size USIZE and | |
| 263 | +** give the HASH, or it is refused. The hash of a delta is checked only | |
| 264 | +** if DELTASRC is at hand. A clone is not checked here. | |
| 261 | 265 | ** |
| 262 | 266 | ** Any artifact successfully received by this routine is considered to |
| 263 | 267 | ** be public and is therefore removed from the "private" table. |
| 264 | 268 | */ |
| 265 | 269 | static void xfer_accept_compressed_file( |
| 266 | 270 | Xfer *pXfer, |
| 271 | + int cloneFlag, | |
| 267 | 272 | char **pzUuidList, |
| 268 | 273 | int *pnUuidList |
| 269 | 274 | ){ |
| 270 | 275 | int szC; /* CSIZE */ |
| 271 | 276 | int szU; /* USIZE */ |
| @@ -299,20 +304,60 @@ | ||
| 299 | 304 | } |
| 300 | 305 | if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 301 | 306 | /* Ignore files that have been shunned */ |
| 302 | 307 | blob_reset(&content); |
| 303 | 308 | return; |
| 309 | + } | |
| 310 | + if( szU==0 | |
| 311 | + && (blob_size(&content)<=4 || blob_uncompress(&content, &content)) | |
| 312 | + ){ | |
| 313 | + blob_appendf(&pXfer->err, "malformed cfile content"); | |
| 314 | + blob_reset(&content); | |
| 315 | + return; | |
| 304 | 316 | } |
| 305 | 317 | if( pXfer->nToken==5 ){ |
| 306 | 318 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| 307 | 319 | pXfer->nDeltaRcvd++; |
| 308 | 320 | }else{ |
| 309 | 321 | srcid = 0; |
| 310 | 322 | pXfer->nFileRcvd++; |
| 323 | + } | |
| 324 | + if( !cloneFlag ){ | |
| 325 | + Blob *pUuid = &pXfer->aToken[1]; | |
| 326 | + Blob x; /* The content, uncompressed */ | |
| 327 | + Blob src, next; /* Source of a delta, and the delta applied to it */ | |
| 328 | + int ok = 1; | |
| 329 | + blob_zero(&x); | |
| 330 | + if( szU==0 ){ | |
| 331 | + blob_copy(&x, &content); | |
| 332 | + }else if( blob_size(&content)<=4 || blob_uncompress(&content, &x) ){ | |
| 333 | + blob_appendf(&pXfer->err, "malformed cfile content"); | |
| 334 | + blob_reset(&content); | |
| 335 | + return; | |
| 336 | + } | |
| 337 | + if( srcid==0 ){ | |
| 338 | + ok = (int)blob_size(&x)==szU | |
| 339 | + && hname_verify_hash(&x, blob_buffer(pUuid), blob_size(pUuid)); | |
| 340 | + }else if( delta_output_size(blob_buffer(&x), blob_size(&x))!=szU ){ | |
| 341 | + ok = 0; | |
| 342 | + }else if( content_get(srcid, &src) ){ | |
| 343 | + blob_zero(&next); | |
| 344 | + ok = blob_delta_apply(&src, &x, &next)>=0 | |
| 345 | + && hname_verify_hash(&next, blob_buffer(pUuid), blob_size(pUuid)); | |
| 346 | + blob_reset(&next); | |
| 347 | + blob_reset(&src); | |
| 348 | + } | |
| 349 | + blob_reset(&x); | |
| 350 | + if( !ok ){ | |
| 351 | + blob_appendf(&pXfer->err, | |
| 352 | + "wrong size or hash on received artifact: %b", pUuid); | |
| 353 | + blob_reset(&content); | |
| 354 | + return; | |
| 355 | + } | |
| 311 | 356 | } |
| 312 | 357 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, |
| 313 | - szC, isPriv); | |
| 358 | + szU, isPriv); | |
| 314 | 359 | Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]), |
| 315 | 360 | blob_size(&pXfer->aToken[1])); |
| 316 | 361 | remote_has(rid); |
| 317 | 362 | blob_reset(&content); |
| 318 | 363 | } |
| @@ -381,10 +426,13 @@ | ||
| 381 | 426 | goto end_accept_unversioned_file; |
| 382 | 427 | } |
| 383 | 428 | |
| 384 | 429 | /* Make sure we have a valid g.rcvid marker */ |
| 385 | 430 | content_rcvid_init(0); |
| 431 | + | |
| 432 | + /* The table might not exist yet if the other side sent no uv-hash pragma */ | |
| 433 | + unversioned_schema(); | |
| 386 | 434 | |
| 387 | 435 | /* Check to see if current content really should be overwritten. Ideally, |
| 388 | 436 | ** a uvfile card should never have been sent unless the overwrite should |
| 389 | 437 | ** occur. But do not trust the sender. Double-check. |
| 390 | 438 | */ |
| @@ -737,10 +785,11 @@ | ||
| 737 | 785 | int isClient /* True if sending from client to server */ |
| 738 | 786 | ){ |
| 739 | 787 | Stmt q1; |
| 740 | 788 | int isFull = !isClient && (int)blob_size(pXfer->pOut)>=pXfer->mxSend; |
| 741 | 789 | |
| 790 | + unversioned_schema(); | |
| 742 | 791 | if( isFull ) noContent = 1; |
| 743 | 792 | if( noContent ){ |
| 744 | 793 | db_prepare(&q1, |
| 745 | 794 | "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q", |
| 746 | 795 | zName |
| @@ -1415,11 +1464,11 @@ | ||
| 1415 | 1464 | cgi_reset_content(); |
| 1416 | 1465 | @ error not\sauthorized\sto\swrite%s(whyNotAuth()) |
| 1417 | 1466 | nErr++; |
| 1418 | 1467 | break; |
| 1419 | 1468 | } |
| 1420 | - xfer_accept_compressed_file(&xfer, pzUuidList, pnUuidList); | |
| 1469 | + xfer_accept_compressed_file(&xfer, 0, pzUuidList, pnUuidList); | |
| 1421 | 1470 | if( blob_size(&xfer.err) ){ |
| 1422 | 1471 | cgi_reset_content(); |
| 1423 | 1472 | @ error %T(blob_str(&xfer.err)) |
| 1424 | 1473 | nErr++; |
| 1425 | 1474 | break; |
| @@ -2097,10 +2146,22 @@ | ||
| 2097 | 2146 | ** Floating-point absolute value |
| 2098 | 2147 | */ |
| 2099 | 2148 | static double fossil_fabs(double x){ |
| 2100 | 2149 | return x>0.0 ? x : -x; |
| 2101 | 2150 | } |
| 2151 | + | |
| 2152 | +/* | |
| 2153 | +** Tell the user that unversioned content cannot be pushed because the | |
| 2154 | +** server has sent the "uv-pull-only" pragma. | |
| 2155 | +*/ | |
| 2156 | +static void uv_pull_only_warning(void){ | |
| 2157 | + fossil_warning( | |
| 2158 | + "Warning: uv-pull-only \n" | |
| 2159 | + " Unable to push unversioned content because you lack\n" | |
| 2160 | + " sufficient permission on the server\n" | |
| 2161 | + ); | |
| 2162 | +} | |
| 2102 | 2163 | |
| 2103 | 2164 | /* |
| 2104 | 2165 | ** Sync to the host identified in g.url.name and g.url.path. This |
| 2105 | 2166 | ** routine is called by the client. |
| 2106 | 2167 | ** |
| @@ -2176,14 +2237,13 @@ | ||
| 2176 | 2237 | const char *zPX; |
| 2177 | 2238 | configRcvMask = 0; |
| 2178 | 2239 | configSendMask = 0; |
| 2179 | 2240 | syncFlags &= ~(SYNC_PUSH); |
| 2180 | 2241 | zPX = db_get("parent-project-code", 0); |
| 2181 | - if( zPX==0 || db_get("parent-project-name",0)==0 ){ | |
| 2242 | + if( zPX==0 ){ | |
| 2182 | 2243 | fossil_fatal("there is no parent project: set the 'parent-project-code'" |
| 2183 | - " and 'parent-project-name' config parameters in order" | |
| 2184 | - " to pull from a parent project"); | |
| 2244 | + " config parameter in order to pull from a parent project"); | |
| 2185 | 2245 | } |
| 2186 | 2246 | if( zPX ){ |
| 2187 | 2247 | zAltPCode = zPX; |
| 2188 | 2248 | } |
| 2189 | 2249 | } |
| @@ -2584,11 +2644,11 @@ | ||
| 2584 | 2644 | ** Client receives a compressed file transmitted from the server. |
| 2585 | 2645 | */ |
| 2586 | 2646 | if( blob_eq(&xfer.aToken[0],"cfile") |
| 2587 | 2647 | && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 |
| 2588 | 2648 | ){ |
| 2589 | - xfer_accept_compressed_file(&xfer, 0, 0); | |
| 2649 | + xfer_accept_compressed_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0); | |
| 2590 | 2650 | nArtifactRcvd++; |
| 2591 | 2651 | }else |
| 2592 | 2652 | |
| 2593 | 2653 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2594 | 2654 | ** |
| @@ -2731,15 +2791,11 @@ | ||
| 2731 | 2791 | "UPDATE unversioned SET mtime=%lld WHERE name=%Q", mtime, zName |
| 2732 | 2792 | ); |
| 2733 | 2793 | db_unset("uv-hash", 0); |
| 2734 | 2794 | } |
| 2735 | 2795 | if( iStatus>=4 && uvPullOnly==1 ){ |
| 2736 | - fossil_warning( | |
| 2737 | - "Warning: uv-pull-only \n" | |
| 2738 | - " Unable to push unversioned content because you lack\n" | |
| 2739 | - " sufficient permission on the server\n" | |
| 2740 | - ); | |
| 2796 | + uv_pull_only_warning(); | |
| 2741 | 2797 | uvPullOnly = 2; |
| 2742 | 2798 | } |
| 2743 | 2799 | if( iStatus<=3 || uvPullOnly ){ |
| 2744 | 2800 | db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName); |
| 2745 | 2801 | }else if( iStatus==4 ){ |
| @@ -3039,10 +3095,19 @@ | ||
| 3039 | 3095 | } |
| 3040 | 3096 | } |
| 3041 | 3097 | nUncRcvd += blob_size(&recv); |
| 3042 | 3098 | blob_reset(&recv); |
| 3043 | 3099 | nCycle++; |
| 3100 | + | |
| 3101 | + /* Also warn for files that no uvigot card named */ | |
| 3102 | + if( uvPullOnly==1 && (syncFlags & SYNC_UV_REVERT)==0 | |
| 3103 | + && db_exists("SELECT 1 FROM uv_tosend") | |
| 3104 | + ){ | |
| 3105 | + uv_pull_only_warning(); | |
| 3106 | + uvPullOnly = 2; | |
| 3107 | + db_multi_exec("DELETE FROM uv_tosend"); | |
| 3108 | + } | |
| 3044 | 3109 | |
| 3045 | 3110 | /* Set go to 1 if we need to continue the sync/push/pull/clone for |
| 3046 | 3111 | ** another round. Set go to 0 if it is time to quit. */ |
| 3047 | 3112 | nFileRecv = xfer.nFileRcvd + xfer.nDeltaRcvd + xfer.nDanglingFile; |
| 3048 | 3113 | if( (nFileRecv>0 || newPhantom) && db_exists("SELECT 1 FROM phantom") ){ |
| 3049 | 3114 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -256,16 +256,21 @@ | |
| 256 | ** |
| 257 | ** The original size of the HASH artifact is USIZE. |
| 258 | ** |
| 259 | ** If any error occurs, write a message into pErr which has already |
| 260 | ** be initialized to an empty string. |
| 261 | ** |
| 262 | ** Any artifact successfully received by this routine is considered to |
| 263 | ** be public and is therefore removed from the "private" table. |
| 264 | */ |
| 265 | static void xfer_accept_compressed_file( |
| 266 | Xfer *pXfer, |
| 267 | char **pzUuidList, |
| 268 | int *pnUuidList |
| 269 | ){ |
| 270 | int szC; /* CSIZE */ |
| 271 | int szU; /* USIZE */ |
| @@ -299,20 +304,60 @@ | |
| 299 | } |
| 300 | if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 301 | /* Ignore files that have been shunned */ |
| 302 | blob_reset(&content); |
| 303 | return; |
| 304 | } |
| 305 | if( pXfer->nToken==5 ){ |
| 306 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| 307 | pXfer->nDeltaRcvd++; |
| 308 | }else{ |
| 309 | srcid = 0; |
| 310 | pXfer->nFileRcvd++; |
| 311 | } |
| 312 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, |
| 313 | szC, isPriv); |
| 314 | Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]), |
| 315 | blob_size(&pXfer->aToken[1])); |
| 316 | remote_has(rid); |
| 317 | blob_reset(&content); |
| 318 | } |
| @@ -381,10 +426,13 @@ | |
| 381 | goto end_accept_unversioned_file; |
| 382 | } |
| 383 | |
| 384 | /* Make sure we have a valid g.rcvid marker */ |
| 385 | content_rcvid_init(0); |
| 386 | |
| 387 | /* Check to see if current content really should be overwritten. Ideally, |
| 388 | ** a uvfile card should never have been sent unless the overwrite should |
| 389 | ** occur. But do not trust the sender. Double-check. |
| 390 | */ |
| @@ -737,10 +785,11 @@ | |
| 737 | int isClient /* True if sending from client to server */ |
| 738 | ){ |
| 739 | Stmt q1; |
| 740 | int isFull = !isClient && (int)blob_size(pXfer->pOut)>=pXfer->mxSend; |
| 741 | |
| 742 | if( isFull ) noContent = 1; |
| 743 | if( noContent ){ |
| 744 | db_prepare(&q1, |
| 745 | "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q", |
| 746 | zName |
| @@ -1415,11 +1464,11 @@ | |
| 1415 | cgi_reset_content(); |
| 1416 | @ error not\sauthorized\sto\swrite%s(whyNotAuth()) |
| 1417 | nErr++; |
| 1418 | break; |
| 1419 | } |
| 1420 | xfer_accept_compressed_file(&xfer, pzUuidList, pnUuidList); |
| 1421 | if( blob_size(&xfer.err) ){ |
| 1422 | cgi_reset_content(); |
| 1423 | @ error %T(blob_str(&xfer.err)) |
| 1424 | nErr++; |
| 1425 | break; |
| @@ -2097,10 +2146,22 @@ | |
| 2097 | ** Floating-point absolute value |
| 2098 | */ |
| 2099 | static double fossil_fabs(double x){ |
| 2100 | return x>0.0 ? x : -x; |
| 2101 | } |
| 2102 | |
| 2103 | /* |
| 2104 | ** Sync to the host identified in g.url.name and g.url.path. This |
| 2105 | ** routine is called by the client. |
| 2106 | ** |
| @@ -2176,14 +2237,13 @@ | |
| 2176 | const char *zPX; |
| 2177 | configRcvMask = 0; |
| 2178 | configSendMask = 0; |
| 2179 | syncFlags &= ~(SYNC_PUSH); |
| 2180 | zPX = db_get("parent-project-code", 0); |
| 2181 | if( zPX==0 || db_get("parent-project-name",0)==0 ){ |
| 2182 | fossil_fatal("there is no parent project: set the 'parent-project-code'" |
| 2183 | " and 'parent-project-name' config parameters in order" |
| 2184 | " to pull from a parent project"); |
| 2185 | } |
| 2186 | if( zPX ){ |
| 2187 | zAltPCode = zPX; |
| 2188 | } |
| 2189 | } |
| @@ -2584,11 +2644,11 @@ | |
| 2584 | ** Client receives a compressed file transmitted from the server. |
| 2585 | */ |
| 2586 | if( blob_eq(&xfer.aToken[0],"cfile") |
| 2587 | && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 |
| 2588 | ){ |
| 2589 | xfer_accept_compressed_file(&xfer, 0, 0); |
| 2590 | nArtifactRcvd++; |
| 2591 | }else |
| 2592 | |
| 2593 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2594 | ** |
| @@ -2731,15 +2791,11 @@ | |
| 2731 | "UPDATE unversioned SET mtime=%lld WHERE name=%Q", mtime, zName |
| 2732 | ); |
| 2733 | db_unset("uv-hash", 0); |
| 2734 | } |
| 2735 | if( iStatus>=4 && uvPullOnly==1 ){ |
| 2736 | fossil_warning( |
| 2737 | "Warning: uv-pull-only \n" |
| 2738 | " Unable to push unversioned content because you lack\n" |
| 2739 | " sufficient permission on the server\n" |
| 2740 | ); |
| 2741 | uvPullOnly = 2; |
| 2742 | } |
| 2743 | if( iStatus<=3 || uvPullOnly ){ |
| 2744 | db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName); |
| 2745 | }else if( iStatus==4 ){ |
| @@ -3039,10 +3095,19 @@ | |
| 3039 | } |
| 3040 | } |
| 3041 | nUncRcvd += blob_size(&recv); |
| 3042 | blob_reset(&recv); |
| 3043 | nCycle++; |
| 3044 | |
| 3045 | /* Set go to 1 if we need to continue the sync/push/pull/clone for |
| 3046 | ** another round. Set go to 0 if it is time to quit. */ |
| 3047 | nFileRecv = xfer.nFileRcvd + xfer.nDeltaRcvd + xfer.nDanglingFile; |
| 3048 | if( (nFileRecv>0 || newPhantom) && db_exists("SELECT 1 FROM phantom") ){ |
| 3049 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -256,16 +256,21 @@ | |
| 256 | ** |
| 257 | ** The original size of the HASH artifact is USIZE. |
| 258 | ** |
| 259 | ** If any error occurs, write a message into pErr which has already |
| 260 | ** be initialized to an empty string. |
| 261 | ** |
| 262 | ** Unless cloneFlag is set, the content must have the size USIZE and |
| 263 | ** give the HASH, or it is refused. The hash of a delta is checked only |
| 264 | ** if DELTASRC is at hand. A clone is not checked here. |
| 265 | ** |
| 266 | ** Any artifact successfully received by this routine is considered to |
| 267 | ** be public and is therefore removed from the "private" table. |
| 268 | */ |
| 269 | static void xfer_accept_compressed_file( |
| 270 | Xfer *pXfer, |
| 271 | int cloneFlag, |
| 272 | char **pzUuidList, |
| 273 | int *pnUuidList |
| 274 | ){ |
| 275 | int szC; /* CSIZE */ |
| 276 | int szU; /* USIZE */ |
| @@ -299,20 +304,60 @@ | |
| 304 | } |
| 305 | if( uuid_is_shunned(blob_str(&pXfer->aToken[1])) ){ |
| 306 | /* Ignore files that have been shunned */ |
| 307 | blob_reset(&content); |
| 308 | return; |
| 309 | } |
| 310 | if( szU==0 |
| 311 | && (blob_size(&content)<=4 || blob_uncompress(&content, &content)) |
| 312 | ){ |
| 313 | blob_appendf(&pXfer->err, "malformed cfile content"); |
| 314 | blob_reset(&content); |
| 315 | return; |
| 316 | } |
| 317 | if( pXfer->nToken==5 ){ |
| 318 | srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv); |
| 319 | pXfer->nDeltaRcvd++; |
| 320 | }else{ |
| 321 | srcid = 0; |
| 322 | pXfer->nFileRcvd++; |
| 323 | } |
| 324 | if( !cloneFlag ){ |
| 325 | Blob *pUuid = &pXfer->aToken[1]; |
| 326 | Blob x; /* The content, uncompressed */ |
| 327 | Blob src, next; /* Source of a delta, and the delta applied to it */ |
| 328 | int ok = 1; |
| 329 | blob_zero(&x); |
| 330 | if( szU==0 ){ |
| 331 | blob_copy(&x, &content); |
| 332 | }else if( blob_size(&content)<=4 || blob_uncompress(&content, &x) ){ |
| 333 | blob_appendf(&pXfer->err, "malformed cfile content"); |
| 334 | blob_reset(&content); |
| 335 | return; |
| 336 | } |
| 337 | if( srcid==0 ){ |
| 338 | ok = (int)blob_size(&x)==szU |
| 339 | && hname_verify_hash(&x, blob_buffer(pUuid), blob_size(pUuid)); |
| 340 | }else if( delta_output_size(blob_buffer(&x), blob_size(&x))!=szU ){ |
| 341 | ok = 0; |
| 342 | }else if( content_get(srcid, &src) ){ |
| 343 | blob_zero(&next); |
| 344 | ok = blob_delta_apply(&src, &x, &next)>=0 |
| 345 | && hname_verify_hash(&next, blob_buffer(pUuid), blob_size(pUuid)); |
| 346 | blob_reset(&next); |
| 347 | blob_reset(&src); |
| 348 | } |
| 349 | blob_reset(&x); |
| 350 | if( !ok ){ |
| 351 | blob_appendf(&pXfer->err, |
| 352 | "wrong size or hash on received artifact: %b", pUuid); |
| 353 | blob_reset(&content); |
| 354 | return; |
| 355 | } |
| 356 | } |
| 357 | rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid, |
| 358 | szU, isPriv); |
| 359 | Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]), |
| 360 | blob_size(&pXfer->aToken[1])); |
| 361 | remote_has(rid); |
| 362 | blob_reset(&content); |
| 363 | } |
| @@ -381,10 +426,13 @@ | |
| 426 | goto end_accept_unversioned_file; |
| 427 | } |
| 428 | |
| 429 | /* Make sure we have a valid g.rcvid marker */ |
| 430 | content_rcvid_init(0); |
| 431 | |
| 432 | /* The table might not exist yet if the other side sent no uv-hash pragma */ |
| 433 | unversioned_schema(); |
| 434 | |
| 435 | /* Check to see if current content really should be overwritten. Ideally, |
| 436 | ** a uvfile card should never have been sent unless the overwrite should |
| 437 | ** occur. But do not trust the sender. Double-check. |
| 438 | */ |
| @@ -737,10 +785,11 @@ | |
| 785 | int isClient /* True if sending from client to server */ |
| 786 | ){ |
| 787 | Stmt q1; |
| 788 | int isFull = !isClient && (int)blob_size(pXfer->pOut)>=pXfer->mxSend; |
| 789 | |
| 790 | unversioned_schema(); |
| 791 | if( isFull ) noContent = 1; |
| 792 | if( noContent ){ |
| 793 | db_prepare(&q1, |
| 794 | "SELECT mtime, hash, encoding, sz FROM unversioned WHERE name=%Q", |
| 795 | zName |
| @@ -1415,11 +1464,11 @@ | |
| 1464 | cgi_reset_content(); |
| 1465 | @ error not\sauthorized\sto\swrite%s(whyNotAuth()) |
| 1466 | nErr++; |
| 1467 | break; |
| 1468 | } |
| 1469 | xfer_accept_compressed_file(&xfer, 0, pzUuidList, pnUuidList); |
| 1470 | if( blob_size(&xfer.err) ){ |
| 1471 | cgi_reset_content(); |
| 1472 | @ error %T(blob_str(&xfer.err)) |
| 1473 | nErr++; |
| 1474 | break; |
| @@ -2097,10 +2146,22 @@ | |
| 2146 | ** Floating-point absolute value |
| 2147 | */ |
| 2148 | static double fossil_fabs(double x){ |
| 2149 | return x>0.0 ? x : -x; |
| 2150 | } |
| 2151 | |
| 2152 | /* |
| 2153 | ** Tell the user that unversioned content cannot be pushed because the |
| 2154 | ** server has sent the "uv-pull-only" pragma. |
| 2155 | */ |
| 2156 | static void uv_pull_only_warning(void){ |
| 2157 | fossil_warning( |
| 2158 | "Warning: uv-pull-only \n" |
| 2159 | " Unable to push unversioned content because you lack\n" |
| 2160 | " sufficient permission on the server\n" |
| 2161 | ); |
| 2162 | } |
| 2163 | |
| 2164 | /* |
| 2165 | ** Sync to the host identified in g.url.name and g.url.path. This |
| 2166 | ** routine is called by the client. |
| 2167 | ** |
| @@ -2176,14 +2237,13 @@ | |
| 2237 | const char *zPX; |
| 2238 | configRcvMask = 0; |
| 2239 | configSendMask = 0; |
| 2240 | syncFlags &= ~(SYNC_PUSH); |
| 2241 | zPX = db_get("parent-project-code", 0); |
| 2242 | if( zPX==0 ){ |
| 2243 | fossil_fatal("there is no parent project: set the 'parent-project-code'" |
| 2244 | " config parameter in order to pull from a parent project"); |
| 2245 | } |
| 2246 | if( zPX ){ |
| 2247 | zAltPCode = zPX; |
| 2248 | } |
| 2249 | } |
| @@ -2584,11 +2644,11 @@ | |
| 2644 | ** Client receives a compressed file transmitted from the server. |
| 2645 | */ |
| 2646 | if( blob_eq(&xfer.aToken[0],"cfile") |
| 2647 | && (syncFlags & (SYNC_PULL|SYNC_CLONE))!=0 |
| 2648 | ){ |
| 2649 | xfer_accept_compressed_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0); |
| 2650 | nArtifactRcvd++; |
| 2651 | }else |
| 2652 | |
| 2653 | /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT |
| 2654 | ** |
| @@ -2731,15 +2791,11 @@ | |
| 2791 | "UPDATE unversioned SET mtime=%lld WHERE name=%Q", mtime, zName |
| 2792 | ); |
| 2793 | db_unset("uv-hash", 0); |
| 2794 | } |
| 2795 | if( iStatus>=4 && uvPullOnly==1 ){ |
| 2796 | uv_pull_only_warning(); |
| 2797 | uvPullOnly = 2; |
| 2798 | } |
| 2799 | if( iStatus<=3 || uvPullOnly ){ |
| 2800 | db_multi_exec("DELETE FROM uv_tosend WHERE name=%Q", zName); |
| 2801 | }else if( iStatus==4 ){ |
| @@ -3039,10 +3095,19 @@ | |
| 3095 | } |
| 3096 | } |
| 3097 | nUncRcvd += blob_size(&recv); |
| 3098 | blob_reset(&recv); |
| 3099 | nCycle++; |
| 3100 | |
| 3101 | /* Also warn for files that no uvigot card named */ |
| 3102 | if( uvPullOnly==1 && (syncFlags & SYNC_UV_REVERT)==0 |
| 3103 | && db_exists("SELECT 1 FROM uv_tosend") |
| 3104 | ){ |
| 3105 | uv_pull_only_warning(); |
| 3106 | uvPullOnly = 2; |
| 3107 | db_multi_exec("DELETE FROM uv_tosend"); |
| 3108 | } |
| 3109 | |
| 3110 | /* Set go to 1 if we need to continue the sync/push/pull/clone for |
| 3111 | ** another round. Set go to 0 if it is time to quit. */ |
| 3112 | nFileRecv = xfer.nFileRcvd + xfer.nDeltaRcvd + xfer.nDanglingFile; |
| 3113 | if( (nFileRecv>0 || newPhantom) && db_exists("SELECT 1 FROM phantom") ){ |
| 3114 |