Fossil SCM
Merge enhancements from trunk.
Commit
1e3779959dd097d29535b33584eb022991d42895
Parent
c3fbab2edb6123f…
1 file changed
+28
-2
+28
-2
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -49,10 +49,11 @@ | ||
| 49 | 49 | int nDanglingFile; /* Number of dangling deltas received */ |
| 50 | 50 | int mxSend; /* Stop sending "file" when pOut reaches this size */ |
| 51 | 51 | int resync; /* Send igot cards for all holdings */ |
| 52 | 52 | u8 syncPrivate; /* True to enable syncing private content */ |
| 53 | 53 | u8 nextIsPrivate; /* If true, next "file" received is a private */ |
| 54 | + u32 clientVersion; /* Version of the client software */ | |
| 54 | 55 | time_t maxTime; /* Time when this transfer should be finished */ |
| 55 | 56 | }; |
| 56 | 57 | |
| 57 | 58 | |
| 58 | 59 | /* |
| @@ -493,10 +494,21 @@ | ||
| 493 | 494 | }else{ |
| 494 | 495 | size = 0; |
| 495 | 496 | } |
| 496 | 497 | return size; |
| 497 | 498 | } |
| 499 | + | |
| 500 | +/* | |
| 501 | +** Push an error message to alert the older client that the repository | |
| 502 | +** has SHA3 content and cannot be synced or cloned. | |
| 503 | +*/ | |
| 504 | +static void xfer_cannot_send_sha3_error(Xfer *pXfer){ | |
| 505 | + blob_appendf(pXfer->pOut, | |
| 506 | + "error Fossil\\sversion\\s2.0\\sor\\slater\\srequired.\n" | |
| 507 | + ); | |
| 508 | +} | |
| 509 | + | |
| 498 | 510 | |
| 499 | 511 | /* |
| 500 | 512 | ** Send the file identified by rid. |
| 501 | 513 | ** |
| 502 | 514 | ** The pUuid can be NULL in which case the correct hash is computed |
| @@ -520,10 +532,14 @@ | ||
| 520 | 532 | } |
| 521 | 533 | blob_zero(&uuid); |
| 522 | 534 | db_blob(&uuid, "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid); |
| 523 | 535 | if( blob_size(&uuid)==0 ){ |
| 524 | 536 | return; |
| 537 | + } | |
| 538 | + if( blob_size(&uuid)>HNAME_LEN_SHA1 && pXfer->clientVersion<20000 ){ | |
| 539 | + xfer_cannot_send_sha3_error(pXfer); | |
| 540 | + return; | |
| 525 | 541 | } |
| 526 | 542 | if( pUuid ){ |
| 527 | 543 | if( blob_compare(pUuid, &uuid)!=0 ){ |
| 528 | 544 | blob_reset(&uuid); |
| 529 | 545 | return; |
| @@ -610,10 +626,15 @@ | ||
| 610 | 626 | szC = db_column_bytes(&q1, 2); |
| 611 | 627 | zContent = db_column_raw(&q1, 2); |
| 612 | 628 | srcIsPrivate = db_column_int(&q1, 3); |
| 613 | 629 | zDelta = db_column_text(&q1, 4); |
| 614 | 630 | if( isPrivate ) blob_append(pXfer->pOut, "private\n", -1); |
| 631 | + if( pXfer->clientVersion<20000 && db_column_bytes(&q1,0)!=HNAME_LEN_SHA1 ){ | |
| 632 | + xfer_cannot_send_sha3_error(pXfer); | |
| 633 | + db_reset(&q1); | |
| 634 | + return; | |
| 635 | + } | |
| 615 | 636 | blob_appendf(pXfer->pOut, "cfile %s ", zUuid); |
| 616 | 637 | if( !isPrivate && srcIsPrivate ){ |
| 617 | 638 | content_get(rid, &fullContent); |
| 618 | 639 | szU = blob_size(&fullContent); |
| 619 | 640 | blob_compress(&fullContent, &fullContent); |
| @@ -669,10 +690,15 @@ | ||
| 669 | 690 | ); |
| 670 | 691 | } |
| 671 | 692 | if( db_step(&q1)==SQLITE_ROW ){ |
| 672 | 693 | sqlite3_int64 mtime = db_column_int64(&q1, 0); |
| 673 | 694 | const char *zHash = db_column_text(&q1, 1); |
| 695 | + if( pXfer->clientVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){ | |
| 696 | + xfer_cannot_send_sha3_error(pXfer); | |
| 697 | + db_reset(&q1); | |
| 698 | + return; | |
| 699 | + } | |
| 674 | 700 | if( blob_size(pXfer->pOut)>=pXfer->mxSend ){ |
| 675 | 701 | /* If we have already reached the send size limit, send a (short) |
| 676 | 702 | ** uvigot card rather than a uvfile card. This only happens on the |
| 677 | 703 | ** server side. The uvigot card will provoke the client to resend |
| 678 | 704 | ** another uvgimme on the next cycle. */ |
| @@ -1147,11 +1173,10 @@ | ||
| 1147 | 1173 | char *zUuidList = 0; |
| 1148 | 1174 | int nUuidList = 0; |
| 1149 | 1175 | char **pzUuidList = 0; |
| 1150 | 1176 | int *pnUuidList = 0; |
| 1151 | 1177 | int uvCatalogSent = 0; |
| 1152 | - int clientVersion = 0; /* Version number of the client */ | |
| 1153 | 1178 | |
| 1154 | 1179 | if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){ |
| 1155 | 1180 | fossil_redirect_home(); |
| 1156 | 1181 | } |
| 1157 | 1182 | g.zLogin = "anonymous"; |
| @@ -1534,11 +1559,11 @@ | ||
| 1534 | 1559 | /* pragma client-version VERSION |
| 1535 | 1560 | ** |
| 1536 | 1561 | ** Let the server know what version of Fossil is running on the client. |
| 1537 | 1562 | */ |
| 1538 | 1563 | if( xfer.nToken>=3 && blob_eq(&xfer.aToken[1], "client-version") ){ |
| 1539 | - clientVersion = atoi(blob_str(&xfer.aToken[2])); | |
| 1564 | + xfer.clientVersion = atoi(blob_str(&xfer.aToken[2])); | |
| 1540 | 1565 | } |
| 1541 | 1566 | |
| 1542 | 1567 | /* pragma uv-hash HASH |
| 1543 | 1568 | ** |
| 1544 | 1569 | ** The client wants to make sure that unversioned files are all synced. |
| @@ -1980,10 +2005,11 @@ | ||
| 1980 | 2005 | xfer.nGimmeSent = 0; |
| 1981 | 2006 | xfer.nIGotSent = 0; |
| 1982 | 2007 | |
| 1983 | 2008 | lastPctDone = -1; |
| 1984 | 2009 | blob_reset(&send); |
| 2010 | + blob_appendf(&send, "pragma client-version %d\n", RELEASE_VERSION_NUMBER); | |
| 1985 | 2011 | rArrivalTime = db_double(0.0, "SELECT julianday('now')"); |
| 1986 | 2012 | |
| 1987 | 2013 | /* Send the send-private pragma if we are trying to sync private data */ |
| 1988 | 2014 | if( syncFlags & SYNC_PRIVATE ){ |
| 1989 | 2015 | blob_append(&send, "pragma send-private\n", -1); |
| 1990 | 2016 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -49,10 +49,11 @@ | |
| 49 | int nDanglingFile; /* Number of dangling deltas received */ |
| 50 | int mxSend; /* Stop sending "file" when pOut reaches this size */ |
| 51 | int resync; /* Send igot cards for all holdings */ |
| 52 | u8 syncPrivate; /* True to enable syncing private content */ |
| 53 | u8 nextIsPrivate; /* If true, next "file" received is a private */ |
| 54 | time_t maxTime; /* Time when this transfer should be finished */ |
| 55 | }; |
| 56 | |
| 57 | |
| 58 | /* |
| @@ -493,10 +494,21 @@ | |
| 493 | }else{ |
| 494 | size = 0; |
| 495 | } |
| 496 | return size; |
| 497 | } |
| 498 | |
| 499 | /* |
| 500 | ** Send the file identified by rid. |
| 501 | ** |
| 502 | ** The pUuid can be NULL in which case the correct hash is computed |
| @@ -520,10 +532,14 @@ | |
| 520 | } |
| 521 | blob_zero(&uuid); |
| 522 | db_blob(&uuid, "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid); |
| 523 | if( blob_size(&uuid)==0 ){ |
| 524 | return; |
| 525 | } |
| 526 | if( pUuid ){ |
| 527 | if( blob_compare(pUuid, &uuid)!=0 ){ |
| 528 | blob_reset(&uuid); |
| 529 | return; |
| @@ -610,10 +626,15 @@ | |
| 610 | szC = db_column_bytes(&q1, 2); |
| 611 | zContent = db_column_raw(&q1, 2); |
| 612 | srcIsPrivate = db_column_int(&q1, 3); |
| 613 | zDelta = db_column_text(&q1, 4); |
| 614 | if( isPrivate ) blob_append(pXfer->pOut, "private\n", -1); |
| 615 | blob_appendf(pXfer->pOut, "cfile %s ", zUuid); |
| 616 | if( !isPrivate && srcIsPrivate ){ |
| 617 | content_get(rid, &fullContent); |
| 618 | szU = blob_size(&fullContent); |
| 619 | blob_compress(&fullContent, &fullContent); |
| @@ -669,10 +690,15 @@ | |
| 669 | ); |
| 670 | } |
| 671 | if( db_step(&q1)==SQLITE_ROW ){ |
| 672 | sqlite3_int64 mtime = db_column_int64(&q1, 0); |
| 673 | const char *zHash = db_column_text(&q1, 1); |
| 674 | if( blob_size(pXfer->pOut)>=pXfer->mxSend ){ |
| 675 | /* If we have already reached the send size limit, send a (short) |
| 676 | ** uvigot card rather than a uvfile card. This only happens on the |
| 677 | ** server side. The uvigot card will provoke the client to resend |
| 678 | ** another uvgimme on the next cycle. */ |
| @@ -1147,11 +1173,10 @@ | |
| 1147 | char *zUuidList = 0; |
| 1148 | int nUuidList = 0; |
| 1149 | char **pzUuidList = 0; |
| 1150 | int *pnUuidList = 0; |
| 1151 | int uvCatalogSent = 0; |
| 1152 | int clientVersion = 0; /* Version number of the client */ |
| 1153 | |
| 1154 | if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){ |
| 1155 | fossil_redirect_home(); |
| 1156 | } |
| 1157 | g.zLogin = "anonymous"; |
| @@ -1534,11 +1559,11 @@ | |
| 1534 | /* pragma client-version VERSION |
| 1535 | ** |
| 1536 | ** Let the server know what version of Fossil is running on the client. |
| 1537 | */ |
| 1538 | if( xfer.nToken>=3 && blob_eq(&xfer.aToken[1], "client-version") ){ |
| 1539 | clientVersion = atoi(blob_str(&xfer.aToken[2])); |
| 1540 | } |
| 1541 | |
| 1542 | /* pragma uv-hash HASH |
| 1543 | ** |
| 1544 | ** The client wants to make sure that unversioned files are all synced. |
| @@ -1980,10 +2005,11 @@ | |
| 1980 | xfer.nGimmeSent = 0; |
| 1981 | xfer.nIGotSent = 0; |
| 1982 | |
| 1983 | lastPctDone = -1; |
| 1984 | blob_reset(&send); |
| 1985 | rArrivalTime = db_double(0.0, "SELECT julianday('now')"); |
| 1986 | |
| 1987 | /* Send the send-private pragma if we are trying to sync private data */ |
| 1988 | if( syncFlags & SYNC_PRIVATE ){ |
| 1989 | blob_append(&send, "pragma send-private\n", -1); |
| 1990 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -49,10 +49,11 @@ | |
| 49 | int nDanglingFile; /* Number of dangling deltas received */ |
| 50 | int mxSend; /* Stop sending "file" when pOut reaches this size */ |
| 51 | int resync; /* Send igot cards for all holdings */ |
| 52 | u8 syncPrivate; /* True to enable syncing private content */ |
| 53 | u8 nextIsPrivate; /* If true, next "file" received is a private */ |
| 54 | u32 clientVersion; /* Version of the client software */ |
| 55 | time_t maxTime; /* Time when this transfer should be finished */ |
| 56 | }; |
| 57 | |
| 58 | |
| 59 | /* |
| @@ -493,10 +494,21 @@ | |
| 494 | }else{ |
| 495 | size = 0; |
| 496 | } |
| 497 | return size; |
| 498 | } |
| 499 | |
| 500 | /* |
| 501 | ** Push an error message to alert the older client that the repository |
| 502 | ** has SHA3 content and cannot be synced or cloned. |
| 503 | */ |
| 504 | static void xfer_cannot_send_sha3_error(Xfer *pXfer){ |
| 505 | blob_appendf(pXfer->pOut, |
| 506 | "error Fossil\\sversion\\s2.0\\sor\\slater\\srequired.\n" |
| 507 | ); |
| 508 | } |
| 509 | |
| 510 | |
| 511 | /* |
| 512 | ** Send the file identified by rid. |
| 513 | ** |
| 514 | ** The pUuid can be NULL in which case the correct hash is computed |
| @@ -520,10 +532,14 @@ | |
| 532 | } |
| 533 | blob_zero(&uuid); |
| 534 | db_blob(&uuid, "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid); |
| 535 | if( blob_size(&uuid)==0 ){ |
| 536 | return; |
| 537 | } |
| 538 | if( blob_size(&uuid)>HNAME_LEN_SHA1 && pXfer->clientVersion<20000 ){ |
| 539 | xfer_cannot_send_sha3_error(pXfer); |
| 540 | return; |
| 541 | } |
| 542 | if( pUuid ){ |
| 543 | if( blob_compare(pUuid, &uuid)!=0 ){ |
| 544 | blob_reset(&uuid); |
| 545 | return; |
| @@ -610,10 +626,15 @@ | |
| 626 | szC = db_column_bytes(&q1, 2); |
| 627 | zContent = db_column_raw(&q1, 2); |
| 628 | srcIsPrivate = db_column_int(&q1, 3); |
| 629 | zDelta = db_column_text(&q1, 4); |
| 630 | if( isPrivate ) blob_append(pXfer->pOut, "private\n", -1); |
| 631 | if( pXfer->clientVersion<20000 && db_column_bytes(&q1,0)!=HNAME_LEN_SHA1 ){ |
| 632 | xfer_cannot_send_sha3_error(pXfer); |
| 633 | db_reset(&q1); |
| 634 | return; |
| 635 | } |
| 636 | blob_appendf(pXfer->pOut, "cfile %s ", zUuid); |
| 637 | if( !isPrivate && srcIsPrivate ){ |
| 638 | content_get(rid, &fullContent); |
| 639 | szU = blob_size(&fullContent); |
| 640 | blob_compress(&fullContent, &fullContent); |
| @@ -669,10 +690,15 @@ | |
| 690 | ); |
| 691 | } |
| 692 | if( db_step(&q1)==SQLITE_ROW ){ |
| 693 | sqlite3_int64 mtime = db_column_int64(&q1, 0); |
| 694 | const char *zHash = db_column_text(&q1, 1); |
| 695 | if( pXfer->clientVersion<20000 && db_column_bytes(&q1,1)>HNAME_LEN_SHA1 ){ |
| 696 | xfer_cannot_send_sha3_error(pXfer); |
| 697 | db_reset(&q1); |
| 698 | return; |
| 699 | } |
| 700 | if( blob_size(pXfer->pOut)>=pXfer->mxSend ){ |
| 701 | /* If we have already reached the send size limit, send a (short) |
| 702 | ** uvigot card rather than a uvfile card. This only happens on the |
| 703 | ** server side. The uvigot card will provoke the client to resend |
| 704 | ** another uvgimme on the next cycle. */ |
| @@ -1147,11 +1173,10 @@ | |
| 1173 | char *zUuidList = 0; |
| 1174 | int nUuidList = 0; |
| 1175 | char **pzUuidList = 0; |
| 1176 | int *pnUuidList = 0; |
| 1177 | int uvCatalogSent = 0; |
| 1178 | |
| 1179 | if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){ |
| 1180 | fossil_redirect_home(); |
| 1181 | } |
| 1182 | g.zLogin = "anonymous"; |
| @@ -1534,11 +1559,11 @@ | |
| 1559 | /* pragma client-version VERSION |
| 1560 | ** |
| 1561 | ** Let the server know what version of Fossil is running on the client. |
| 1562 | */ |
| 1563 | if( xfer.nToken>=3 && blob_eq(&xfer.aToken[1], "client-version") ){ |
| 1564 | xfer.clientVersion = atoi(blob_str(&xfer.aToken[2])); |
| 1565 | } |
| 1566 | |
| 1567 | /* pragma uv-hash HASH |
| 1568 | ** |
| 1569 | ** The client wants to make sure that unversioned files are all synced. |
| @@ -1980,10 +2005,11 @@ | |
| 2005 | xfer.nGimmeSent = 0; |
| 2006 | xfer.nIGotSent = 0; |
| 2007 | |
| 2008 | lastPctDone = -1; |
| 2009 | blob_reset(&send); |
| 2010 | blob_appendf(&send, "pragma client-version %d\n", RELEASE_VERSION_NUMBER); |
| 2011 | rArrivalTime = db_double(0.0, "SELECT julianday('now')"); |
| 2012 | |
| 2013 | /* Send the send-private pragma if we are trying to sync private data */ |
| 2014 | if( syncFlags & SYNC_PRIVATE ){ |
| 2015 | blob_append(&send, "pragma send-private\n", -1); |
| 2016 |