Fossil SCM

Merge enhancements from trunk.

drh 2017-03-01 17:49 fossil-2.1 merge
Commit 1e3779959dd097d29535b33584eb022991d42895
1 file changed +28 -2
+28 -2
--- src/xfer.c
+++ src/xfer.c
@@ -49,10 +49,11 @@
4949
int nDanglingFile; /* Number of dangling deltas received */
5050
int mxSend; /* Stop sending "file" when pOut reaches this size */
5151
int resync; /* Send igot cards for all holdings */
5252
u8 syncPrivate; /* True to enable syncing private content */
5353
u8 nextIsPrivate; /* If true, next "file" received is a private */
54
+ u32 clientVersion; /* Version of the client software */
5455
time_t maxTime; /* Time when this transfer should be finished */
5556
};
5657
5758
5859
/*
@@ -493,10 +494,21 @@
493494
}else{
494495
size = 0;
495496
}
496497
return size;
497498
}
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
+
498510
499511
/*
500512
** Send the file identified by rid.
501513
**
502514
** The pUuid can be NULL in which case the correct hash is computed
@@ -520,10 +532,14 @@
520532
}
521533
blob_zero(&uuid);
522534
db_blob(&uuid, "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
523535
if( blob_size(&uuid)==0 ){
524536
return;
537
+ }
538
+ if( blob_size(&uuid)>HNAME_LEN_SHA1 && pXfer->clientVersion<20000 ){
539
+ xfer_cannot_send_sha3_error(pXfer);
540
+ return;
525541
}
526542
if( pUuid ){
527543
if( blob_compare(pUuid, &uuid)!=0 ){
528544
blob_reset(&uuid);
529545
return;
@@ -610,10 +626,15 @@
610626
szC = db_column_bytes(&q1, 2);
611627
zContent = db_column_raw(&q1, 2);
612628
srcIsPrivate = db_column_int(&q1, 3);
613629
zDelta = db_column_text(&q1, 4);
614630
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
+ }
615636
blob_appendf(pXfer->pOut, "cfile %s ", zUuid);
616637
if( !isPrivate && srcIsPrivate ){
617638
content_get(rid, &fullContent);
618639
szU = blob_size(&fullContent);
619640
blob_compress(&fullContent, &fullContent);
@@ -669,10 +690,15 @@
669690
);
670691
}
671692
if( db_step(&q1)==SQLITE_ROW ){
672693
sqlite3_int64 mtime = db_column_int64(&q1, 0);
673694
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
+ }
674700
if( blob_size(pXfer->pOut)>=pXfer->mxSend ){
675701
/* If we have already reached the send size limit, send a (short)
676702
** uvigot card rather than a uvfile card. This only happens on the
677703
** server side. The uvigot card will provoke the client to resend
678704
** another uvgimme on the next cycle. */
@@ -1147,11 +1173,10 @@
11471173
char *zUuidList = 0;
11481174
int nUuidList = 0;
11491175
char **pzUuidList = 0;
11501176
int *pnUuidList = 0;
11511177
int uvCatalogSent = 0;
1152
- int clientVersion = 0; /* Version number of the client */
11531178
11541179
if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
11551180
fossil_redirect_home();
11561181
}
11571182
g.zLogin = "anonymous";
@@ -1534,11 +1559,11 @@
15341559
/* pragma client-version VERSION
15351560
**
15361561
** Let the server know what version of Fossil is running on the client.
15371562
*/
15381563
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]));
15401565
}
15411566
15421567
/* pragma uv-hash HASH
15431568
**
15441569
** The client wants to make sure that unversioned files are all synced.
@@ -1980,10 +2005,11 @@
19802005
xfer.nGimmeSent = 0;
19812006
xfer.nIGotSent = 0;
19822007
19832008
lastPctDone = -1;
19842009
blob_reset(&send);
2010
+ blob_appendf(&send, "pragma client-version %d\n", RELEASE_VERSION_NUMBER);
19852011
rArrivalTime = db_double(0.0, "SELECT julianday('now')");
19862012
19872013
/* Send the send-private pragma if we are trying to sync private data */
19882014
if( syncFlags & SYNC_PRIVATE ){
19892015
blob_append(&send, "pragma send-private\n", -1);
19902016
--- 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

Keyboard Shortcuts

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