Fossil SCM

Relax size constraints on artifact hash parsing.

drh 2017-02-28 00:56 fossil-2.0
Commit 65c597119c22519ac23fa4c8a59bd90d40c730f8
+3 -3
--- src/browse.c
+++ src/browse.c
@@ -345,11 +345,11 @@
345345
** the tree to be constructed properly.
346346
*/
347347
static void tree_add_node(
348348
FileTree *pTree, /* Tree into which nodes are added */
349349
const char *zPath, /* The full pathname of file to add */
350
- const char *zUuid, /* UUID of the file. Might be NULL. */
350
+ const char *zUuid, /* Hash of the file. Might be NULL. */
351351
double mtime /* Modification time for this entry */
352352
){
353353
int i;
354354
FileTreeNode *pParent; /* Parent (directory) of the next node to insert */
355355
@@ -368,20 +368,20 @@
368368
FileTreeNode *pNew;
369369
int iStart = i;
370370
int nByte;
371371
while( zPath[i] && zPath[i]!='/' ){ i++; }
372372
nByte = sizeof(*pNew) + i + 1;
373
- if( zUuid!=0 && zPath[i]==0 ) nByte += UUID_SIZE+1;
373
+ if( zUuid!=0 && zPath[i]==0 ) nByte += HNAME_LEN_MAX+1;
374374
pNew = fossil_malloc( nByte );
375375
memset(pNew, 0, sizeof(*pNew));
376376
pNew->zFullName = (char*)&pNew[1];
377377
memcpy(pNew->zFullName, zPath, i);
378378
pNew->zFullName[i] = 0;
379379
pNew->nFullName = i;
380380
if( zUuid!=0 && zPath[i]==0 ){
381381
pNew->zUuid = pNew->zFullName + i + 1;
382
- memcpy(pNew->zUuid, zUuid, UUID_SIZE+1);
382
+ memcpy(pNew->zUuid, zUuid, strlen(zUuid)+1);
383383
}
384384
pNew->zName = pNew->zFullName + iStart;
385385
if( pTree->pLast ){
386386
pTree->pLast->pNext = pNew;
387387
}else{
388388
--- src/browse.c
+++ src/browse.c
@@ -345,11 +345,11 @@
345 ** the tree to be constructed properly.
346 */
347 static void tree_add_node(
348 FileTree *pTree, /* Tree into which nodes are added */
349 const char *zPath, /* The full pathname of file to add */
350 const char *zUuid, /* UUID of the file. Might be NULL. */
351 double mtime /* Modification time for this entry */
352 ){
353 int i;
354 FileTreeNode *pParent; /* Parent (directory) of the next node to insert */
355
@@ -368,20 +368,20 @@
368 FileTreeNode *pNew;
369 int iStart = i;
370 int nByte;
371 while( zPath[i] && zPath[i]!='/' ){ i++; }
372 nByte = sizeof(*pNew) + i + 1;
373 if( zUuid!=0 && zPath[i]==0 ) nByte += UUID_SIZE+1;
374 pNew = fossil_malloc( nByte );
375 memset(pNew, 0, sizeof(*pNew));
376 pNew->zFullName = (char*)&pNew[1];
377 memcpy(pNew->zFullName, zPath, i);
378 pNew->zFullName[i] = 0;
379 pNew->nFullName = i;
380 if( zUuid!=0 && zPath[i]==0 ){
381 pNew->zUuid = pNew->zFullName + i + 1;
382 memcpy(pNew->zUuid, zUuid, UUID_SIZE+1);
383 }
384 pNew->zName = pNew->zFullName + iStart;
385 if( pTree->pLast ){
386 pTree->pLast->pNext = pNew;
387 }else{
388
--- src/browse.c
+++ src/browse.c
@@ -345,11 +345,11 @@
345 ** the tree to be constructed properly.
346 */
347 static void tree_add_node(
348 FileTree *pTree, /* Tree into which nodes are added */
349 const char *zPath, /* The full pathname of file to add */
350 const char *zUuid, /* Hash of the file. Might be NULL. */
351 double mtime /* Modification time for this entry */
352 ){
353 int i;
354 FileTreeNode *pParent; /* Parent (directory) of the next node to insert */
355
@@ -368,20 +368,20 @@
368 FileTreeNode *pNew;
369 int iStart = i;
370 int nByte;
371 while( zPath[i] && zPath[i]!='/' ){ i++; }
372 nByte = sizeof(*pNew) + i + 1;
373 if( zUuid!=0 && zPath[i]==0 ) nByte += HNAME_LEN_MAX+1;
374 pNew = fossil_malloc( nByte );
375 memset(pNew, 0, sizeof(*pNew));
376 pNew->zFullName = (char*)&pNew[1];
377 memcpy(pNew->zFullName, zPath, i);
378 pNew->zFullName[i] = 0;
379 pNew->nFullName = i;
380 if( zUuid!=0 && zPath[i]==0 ){
381 pNew->zUuid = pNew->zFullName + i + 1;
382 memcpy(pNew->zUuid, zUuid, strlen(zUuid)+1);
383 }
384 pNew->zName = pNew->zFullName + iStart;
385 if( pTree->pLast ){
386 pTree->pLast->pNext = pNew;
387 }else{
388
+8 -8
--- src/shun.c
+++ src/shun.c
@@ -84,18 +84,18 @@
8484
}
8585
zCanonical[j+1] = zCanonical[j] = 0;
8686
p = zCanonical;
8787
while( *p ){
8888
int nUuid = strlen(p);
89
- if( nUuid!=UUID_SIZE || !validate16(p, nUuid) ){
89
+ if( hname_validate(p, nUuid)==HNAME_NONE ){
9090
@ <p class="generalError">Error: Bad artifact IDs.</p>
9191
fossil_free(zCanonical);
9292
zCanonical = 0;
9393
break;
9494
}else{
95
- canonical16(p, UUID_SIZE);
96
- p += UUID_SIZE+1;
95
+ canonical16(p, nUuid);
96
+ p += nUuid+1;
9797
}
9898
}
9999
zUuid = zCanonical;
100100
}
101101
style_header("Shunned Artifacts");
@@ -107,21 +107,21 @@
107107
db_multi_exec("DELETE FROM shun WHERE uuid=%Q", p);
108108
if( !db_exists("SELECT 1 FROM blob WHERE uuid=%Q", p) ){
109109
allExist = 0;
110110
}
111111
admin_log("Unshunned %Q", p);
112
- p += UUID_SIZE+1;
112
+ p += strlen(p)+1;
113113
}
114114
if( allExist ){
115115
@ <p class="noMoreShun">Artifact(s)<br />
116
- for( p = zUuid ; *p ; p += UUID_SIZE+1 ){
116
+ for( p = zUuid ; *p ; p += strlen(p)+1 ){
117117
@ <a href="%R/artifact/%s(p)">%s(p)</a><br />
118118
}
119119
@ are no longer being shunned.</p>
120120
}else{
121121
@ <p class="noMoreShun">Artifact(s)<br />
122
- for( p = zUuid ; *p ; p += UUID_SIZE+1 ){
122
+ for( p = zUuid ; *p ; p += strlen(p)+1 ){
123123
@ %s(p)<br />
124124
}
125125
@ will no longer be shunned. But they may not exist in the repository.
126126
@ It may be necessary to rebuild the repository using the
127127
@ <b>fossil rebuild</b> command-line before the artifact content
@@ -146,14 +146,14 @@
146146
db_multi_exec("DELETE FROM ticket WHERE tkt_uuid=%Q", p);
147147
db_multi_exec("DELETE FROM tag WHERE tagid=%d", tagid);
148148
db_multi_exec("DELETE FROM tagxref WHERE tagid=%d", tagid);
149149
}
150150
admin_log("Shunned %Q", p);
151
- p += UUID_SIZE+1;
151
+ p += strlen(p)+1;
152152
}
153153
@ <p class="shunned">Artifact(s)<br />
154
- for( p = zUuid ; *p ; p += UUID_SIZE+1 ){
154
+ for( p = zUuid ; *p ; p += strlen(p)+1 ){
155155
@ <a href="%R/artifact/%s(p)">%s(p)</a><br />
156156
}
157157
@ have been shunned. They will no longer be pushed.
158158
@ They will be removed from the repository the next time the repository
159159
@ is rebuilt using the <b>fossil rebuild</b> command-line</p>
160160
--- src/shun.c
+++ src/shun.c
@@ -84,18 +84,18 @@
84 }
85 zCanonical[j+1] = zCanonical[j] = 0;
86 p = zCanonical;
87 while( *p ){
88 int nUuid = strlen(p);
89 if( nUuid!=UUID_SIZE || !validate16(p, nUuid) ){
90 @ <p class="generalError">Error: Bad artifact IDs.</p>
91 fossil_free(zCanonical);
92 zCanonical = 0;
93 break;
94 }else{
95 canonical16(p, UUID_SIZE);
96 p += UUID_SIZE+1;
97 }
98 }
99 zUuid = zCanonical;
100 }
101 style_header("Shunned Artifacts");
@@ -107,21 +107,21 @@
107 db_multi_exec("DELETE FROM shun WHERE uuid=%Q", p);
108 if( !db_exists("SELECT 1 FROM blob WHERE uuid=%Q", p) ){
109 allExist = 0;
110 }
111 admin_log("Unshunned %Q", p);
112 p += UUID_SIZE+1;
113 }
114 if( allExist ){
115 @ <p class="noMoreShun">Artifact(s)<br />
116 for( p = zUuid ; *p ; p += UUID_SIZE+1 ){
117 @ <a href="%R/artifact/%s(p)">%s(p)</a><br />
118 }
119 @ are no longer being shunned.</p>
120 }else{
121 @ <p class="noMoreShun">Artifact(s)<br />
122 for( p = zUuid ; *p ; p += UUID_SIZE+1 ){
123 @ %s(p)<br />
124 }
125 @ will no longer be shunned. But they may not exist in the repository.
126 @ It may be necessary to rebuild the repository using the
127 @ <b>fossil rebuild</b> command-line before the artifact content
@@ -146,14 +146,14 @@
146 db_multi_exec("DELETE FROM ticket WHERE tkt_uuid=%Q", p);
147 db_multi_exec("DELETE FROM tag WHERE tagid=%d", tagid);
148 db_multi_exec("DELETE FROM tagxref WHERE tagid=%d", tagid);
149 }
150 admin_log("Shunned %Q", p);
151 p += UUID_SIZE+1;
152 }
153 @ <p class="shunned">Artifact(s)<br />
154 for( p = zUuid ; *p ; p += UUID_SIZE+1 ){
155 @ <a href="%R/artifact/%s(p)">%s(p)</a><br />
156 }
157 @ have been shunned. They will no longer be pushed.
158 @ They will be removed from the repository the next time the repository
159 @ is rebuilt using the <b>fossil rebuild</b> command-line</p>
160
--- src/shun.c
+++ src/shun.c
@@ -84,18 +84,18 @@
84 }
85 zCanonical[j+1] = zCanonical[j] = 0;
86 p = zCanonical;
87 while( *p ){
88 int nUuid = strlen(p);
89 if( hname_validate(p, nUuid)==HNAME_NONE ){
90 @ <p class="generalError">Error: Bad artifact IDs.</p>
91 fossil_free(zCanonical);
92 zCanonical = 0;
93 break;
94 }else{
95 canonical16(p, nUuid);
96 p += nUuid+1;
97 }
98 }
99 zUuid = zCanonical;
100 }
101 style_header("Shunned Artifacts");
@@ -107,21 +107,21 @@
107 db_multi_exec("DELETE FROM shun WHERE uuid=%Q", p);
108 if( !db_exists("SELECT 1 FROM blob WHERE uuid=%Q", p) ){
109 allExist = 0;
110 }
111 admin_log("Unshunned %Q", p);
112 p += strlen(p)+1;
113 }
114 if( allExist ){
115 @ <p class="noMoreShun">Artifact(s)<br />
116 for( p = zUuid ; *p ; p += strlen(p)+1 ){
117 @ <a href="%R/artifact/%s(p)">%s(p)</a><br />
118 }
119 @ are no longer being shunned.</p>
120 }else{
121 @ <p class="noMoreShun">Artifact(s)<br />
122 for( p = zUuid ; *p ; p += strlen(p)+1 ){
123 @ %s(p)<br />
124 }
125 @ will no longer be shunned. But they may not exist in the repository.
126 @ It may be necessary to rebuild the repository using the
127 @ <b>fossil rebuild</b> command-line before the artifact content
@@ -146,14 +146,14 @@
146 db_multi_exec("DELETE FROM ticket WHERE tkt_uuid=%Q", p);
147 db_multi_exec("DELETE FROM tag WHERE tagid=%d", tagid);
148 db_multi_exec("DELETE FROM tagxref WHERE tagid=%d", tagid);
149 }
150 admin_log("Shunned %Q", p);
151 p += strlen(p)+1;
152 }
153 @ <p class="shunned">Artifact(s)<br />
154 for( p = zUuid ; *p ; p += strlen(p)+1 ){
155 @ <a href="%R/artifact/%s(p)">%s(p)</a><br />
156 }
157 @ have been shunned. They will no longer be pushed.
158 @ They will be removed from the repository the next time the repository
159 @ is rebuilt using the <b>fossil rebuild</b> command-line</p>
160
+1 -1
--- src/tag.c
+++ src/tag.c
@@ -627,11 +627,11 @@
627627
blob_init(&value, 0, 0);
628628
for(i=3; i<g.argc; i++){
629629
int pid = name_to_typed_rid(g.argv[i], "ci");
630630
if( i>3 ) blob_append(&value, " ", 1);
631631
zUuid = rid_to_uuid(pid);
632
- blob_append(&value, zUuid, UUID_SIZE);
632
+ blob_append(&value, zUuid, strlen(zUuid));
633633
fossil_free(zUuid);
634634
}
635635
if( bTest && !dryRun ){
636636
tag_insert("parent", 1, blob_str(&value), -1, 0.0, rid);
637637
}else{
638638
--- src/tag.c
+++ src/tag.c
@@ -627,11 +627,11 @@
627 blob_init(&value, 0, 0);
628 for(i=3; i<g.argc; i++){
629 int pid = name_to_typed_rid(g.argv[i], "ci");
630 if( i>3 ) blob_append(&value, " ", 1);
631 zUuid = rid_to_uuid(pid);
632 blob_append(&value, zUuid, UUID_SIZE);
633 fossil_free(zUuid);
634 }
635 if( bTest && !dryRun ){
636 tag_insert("parent", 1, blob_str(&value), -1, 0.0, rid);
637 }else{
638
--- src/tag.c
+++ src/tag.c
@@ -627,11 +627,11 @@
627 blob_init(&value, 0, 0);
628 for(i=3; i<g.argc; i++){
629 int pid = name_to_typed_rid(g.argv[i], "ci");
630 if( i>3 ) blob_append(&value, " ", 1);
631 zUuid = rid_to_uuid(pid);
632 blob_append(&value, zUuid, strlen(zUuid));
633 fossil_free(zUuid);
634 }
635 if( bTest && !dryRun ){
636 tag_insert("parent", 1, blob_str(&value), -1, 0.0, rid);
637 }else{
638
+1 -1
--- src/verify.c
+++ src/verify.c
@@ -40,11 +40,11 @@
4040
if( content_size(rid, 0)<0 ){
4141
return; /* No way to verify phantoms */
4242
}
4343
blob_zero(&uuid);
4444
db_blob(&uuid, "SELECT uuid FROM blob WHERE rid=%d", rid);
45
- if( blob_size(&uuid)!=UUID_SIZE ){
45
+ if( hname_validate(blob_buffer(&uuid), blob_size(&uuid))!=HNAME_NONE ){
4646
fossil_fatal("not a valid rid: %d", rid);
4747
}
4848
if( content_get(rid, &content) ){
4949
sha1sum_blob(&content, &hash);
5050
blob_reset(&content);
5151
--- src/verify.c
+++ src/verify.c
@@ -40,11 +40,11 @@
40 if( content_size(rid, 0)<0 ){
41 return; /* No way to verify phantoms */
42 }
43 blob_zero(&uuid);
44 db_blob(&uuid, "SELECT uuid FROM blob WHERE rid=%d", rid);
45 if( blob_size(&uuid)!=UUID_SIZE ){
46 fossil_fatal("not a valid rid: %d", rid);
47 }
48 if( content_get(rid, &content) ){
49 sha1sum_blob(&content, &hash);
50 blob_reset(&content);
51
--- src/verify.c
+++ src/verify.c
@@ -40,11 +40,11 @@
40 if( content_size(rid, 0)<0 ){
41 return; /* No way to verify phantoms */
42 }
43 blob_zero(&uuid);
44 db_blob(&uuid, "SELECT uuid FROM blob WHERE rid=%d", rid);
45 if( hname_validate(blob_buffer(&uuid), blob_size(&uuid))!=HNAME_NONE ){
46 fossil_fatal("not a valid rid: %d", rid);
47 }
48 if( content_get(rid, &content) ){
49 sha1sum_blob(&content, &hash);
50 blob_reset(&content);
51
+3 -3
--- src/vfile.c
+++ src/vfile.c
@@ -51,17 +51,17 @@
5151
** create a phantom record. A private phantom is created for 2 and
5252
** a public phantom is created for 1.
5353
*/
5454
int uuid_to_rid(const char *zUuid, int phantomize){
5555
int rid, sz;
56
- char z[UUID_SIZE+1];
56
+ char z[HNAME_LEN_MAX+1];
5757
5858
sz = strlen(zUuid);
59
- if( sz!=UUID_SIZE || !validate16(zUuid, sz) ){
59
+ if( hname_validate(zUuid, sz)!=HNAME_NONE ){
6060
return 0;
6161
}
62
- memcpy(z, zUuid, UUID_SIZE+1);
62
+ memcpy(z, zUuid, sz+1);
6363
canonical16(z, sz);
6464
rid = fast_uuid_to_rid(z);
6565
if( rid==0 && phantomize ){
6666
rid = content_new(zUuid, phantomize-1);
6767
}
6868
--- src/vfile.c
+++ src/vfile.c
@@ -51,17 +51,17 @@
51 ** create a phantom record. A private phantom is created for 2 and
52 ** a public phantom is created for 1.
53 */
54 int uuid_to_rid(const char *zUuid, int phantomize){
55 int rid, sz;
56 char z[UUID_SIZE+1];
57
58 sz = strlen(zUuid);
59 if( sz!=UUID_SIZE || !validate16(zUuid, sz) ){
60 return 0;
61 }
62 memcpy(z, zUuid, UUID_SIZE+1);
63 canonical16(z, sz);
64 rid = fast_uuid_to_rid(z);
65 if( rid==0 && phantomize ){
66 rid = content_new(zUuid, phantomize-1);
67 }
68
--- src/vfile.c
+++ src/vfile.c
@@ -51,17 +51,17 @@
51 ** create a phantom record. A private phantom is created for 2 and
52 ** a public phantom is created for 1.
53 */
54 int uuid_to_rid(const char *zUuid, int phantomize){
55 int rid, sz;
56 char z[HNAME_LEN_MAX+1];
57
58 sz = strlen(zUuid);
59 if( hname_validate(zUuid, sz)!=HNAME_NONE ){
60 return 0;
61 }
62 memcpy(z, zUuid, sz+1);
63 canonical16(z, sz);
64 rid = fast_uuid_to_rid(z);
65 if( rid==0 && phantomize ){
66 rid = content_new(zUuid, phantomize-1);
67 }
68
+2 -2
--- src/wiki.c
+++ src/wiki.c
@@ -1122,12 +1122,12 @@
11221122
*/
11231123
int wiki_technote_to_rid(const char *zETime) {
11241124
int rid=0; /* Artifact ID of the tech note */
11251125
int nETime = strlen(zETime);
11261126
Stmt q;
1127
- if( nETime>=4 && nETime<=UUID_SIZE && validate16(zETime, nETime) ){
1128
- char zUuid[UUID_SIZE+1];
1127
+ if( nETime>=4 && hname_validate(zETime, nETime)!=HNAME_NONE ){
1128
+ char zUuid[HNAME_LEN_MAX+1];
11291129
memcpy(zUuid, zETime, nETime+1);
11301130
canonical16(zUuid, nETime);
11311131
db_prepare(&q,
11321132
"SELECT e.objid"
11331133
" FROM event e, tag t"
11341134
--- src/wiki.c
+++ src/wiki.c
@@ -1122,12 +1122,12 @@
1122 */
1123 int wiki_technote_to_rid(const char *zETime) {
1124 int rid=0; /* Artifact ID of the tech note */
1125 int nETime = strlen(zETime);
1126 Stmt q;
1127 if( nETime>=4 && nETime<=UUID_SIZE && validate16(zETime, nETime) ){
1128 char zUuid[UUID_SIZE+1];
1129 memcpy(zUuid, zETime, nETime+1);
1130 canonical16(zUuid, nETime);
1131 db_prepare(&q,
1132 "SELECT e.objid"
1133 " FROM event e, tag t"
1134
--- src/wiki.c
+++ src/wiki.c
@@ -1122,12 +1122,12 @@
1122 */
1123 int wiki_technote_to_rid(const char *zETime) {
1124 int rid=0; /* Artifact ID of the tech note */
1125 int nETime = strlen(zETime);
1126 Stmt q;
1127 if( nETime>=4 && hname_validate(zETime, nETime)!=HNAME_NONE ){
1128 char zUuid[HNAME_LEN_MAX+1];
1129 memcpy(zUuid, zETime, nETime+1);
1130 canonical16(zUuid, nETime);
1131 db_prepare(&q,
1132 "SELECT e.objid"
1133 " FROM event e, tag t"
1134
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1067,11 +1067,11 @@
10671067
** If the input string corresponds to an existing baseline,
10681068
** return true.
10691069
*/
10701070
static int is_valid_uuid(const char *z){
10711071
int n = strlen(z);
1072
- if( n<4 || n>UUID_SIZE ) return 0;
1072
+ if( n<4 || n>HNAME_LEN_MAX ) return 0;
10731073
if( !validate16(z, n) ) return 0;
10741074
return 1;
10751075
}
10761076
10771077
/*
10781078
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1067,11 +1067,11 @@
1067 ** If the input string corresponds to an existing baseline,
1068 ** return true.
1069 */
1070 static int is_valid_uuid(const char *z){
1071 int n = strlen(z);
1072 if( n<4 || n>UUID_SIZE ) return 0;
1073 if( !validate16(z, n) ) return 0;
1074 return 1;
1075 }
1076
1077 /*
1078
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1067,11 +1067,11 @@
1067 ** If the input string corresponds to an existing baseline,
1068 ** return true.
1069 */
1070 static int is_valid_uuid(const char *z){
1071 int n = strlen(z);
1072 if( n<4 || n>HNAME_LEN_MAX ) return 0;
1073 if( !validate16(z, n) ) return 0;
1074 return 1;
1075 }
1076
1077 /*
1078
+21 -21
--- src/xfer.c
+++ src/xfer.c
@@ -54,11 +54,11 @@
5454
time_t maxTime; /* Time when this transfer should be finished */
5555
};
5656
5757
5858
/*
59
-** The input blob contains a UUID. Convert it into a record ID.
59
+** The input blob contains an artifact. Convert it into a record ID.
6060
** Create a phantom record if no prior record exists and
6161
** phantomize is true.
6262
**
6363
** Compare to uuid_to_rid(). This routine takes a blob argument
6464
** and does less error checking.
@@ -100,12 +100,12 @@
100100
** message. This routine finishes parsing that message and does
101101
** a record insert of the file.
102102
**
103103
** The file line is in one of the following two forms:
104104
**
105
-** file UUID SIZE \n CONTENT
106
-** file UUID DELTASRC SIZE \n CONTENT
105
+** file HASH SIZE \n CONTENT
106
+** file HASH DELTASRC SIZE \n CONTENT
107107
**
108108
** The content is SIZE bytes immediately following the newline.
109109
** If DELTASRC exists, then the CONTENT is a delta against the
110110
** content of DELTASRC.
111111
**
@@ -217,18 +217,18 @@
217217
** a record insert of the file. The difference between "file" and
218218
** "cfile" is that with "cfile" the content is already compressed.
219219
**
220220
** The file line is in one of the following two forms:
221221
**
222
-** cfile UUID USIZE CSIZE \n CONTENT
223
-** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
222
+** cfile HASH USIZE CSIZE \n CONTENT
223
+** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
224224
**
225225
** The content is CSIZE bytes immediately following the newline.
226226
** If DELTASRC exists, then the CONTENT is a delta against the
227227
** content of DELTASRC.
228228
**
229
-** The original size of the UUID artifact is USIZE.
229
+** The original size of the HASH artifact is USIZE.
230230
**
231231
** If any error occurs, write a message into pErr which has already
232232
** be initialized to an empty string.
233233
**
234234
** Any artifact successfully received by this routine is considered to
@@ -415,11 +415,11 @@
415415
static int send_delta_parent(
416416
Xfer *pXfer, /* The transfer context */
417417
int rid, /* record id of the file to send */
418418
int isPrivate, /* True if rid is a private artifact */
419419
Blob *pContent, /* The content of the file to send */
420
- Blob *pUuid /* The UUID of the file to send */
420
+ Blob *pUuid /* The HASH of the file to send */
421421
){
422422
static const char *const azQuery[] = {
423423
"SELECT pid FROM plink x"
424424
" WHERE cid=%d"
425425
" AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)",
@@ -469,11 +469,11 @@
469469
*/
470470
static int send_delta_native(
471471
Xfer *pXfer, /* The transfer context */
472472
int rid, /* record id of the file to send */
473473
int isPrivate, /* True if rid is a private artifact */
474
- Blob *pUuid /* The UUID of the file to send */
474
+ Blob *pUuid /* The HASH of the file to send */
475475
){
476476
Blob src, delta;
477477
int size = 0;
478478
int srcId;
479479
@@ -504,11 +504,11 @@
504504
}
505505
506506
/*
507507
** Send the file identified by rid.
508508
**
509
-** The pUuid can be NULL in which case the correct UUID is computed
509
+** The pUuid can be NULL in which case the correct hash is computed
510510
** from the rid.
511511
**
512512
** Try to send the file as a native delta if nativeDelta is true, or
513513
** as a parent delta if nativeDelta is false.
514514
**
@@ -1198,12 +1198,12 @@
11981198
while( blob_line(xfer.pIn, &xfer.line) ){
11991199
if( blob_buffer(&xfer.line)[0]=='#' ) continue;
12001200
if( blob_size(&xfer.line)==0 ) continue;
12011201
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
12021202
1203
- /* file UUID SIZE \n CONTENT
1204
- ** file UUID DELTASRC SIZE \n CONTENT
1203
+ /* file HASH SIZE \n CONTENT
1204
+ ** file HASH DELTASRC SIZE \n CONTENT
12051205
**
12061206
** Accept a file from the client.
12071207
*/
12081208
if( blob_eq(&xfer.aToken[0], "file") ){
12091209
if( !isPush ){
@@ -1219,12 +1219,12 @@
12191219
nErr++;
12201220
break;
12211221
}
12221222
}else
12231223
1224
- /* cfile UUID USIZE CSIZE \n CONTENT
1225
- ** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
1224
+ /* cfile HASH USIZE CSIZE \n CONTENT
1225
+ ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
12261226
**
12271227
** Accept a file from the client.
12281228
*/
12291229
if( blob_eq(&xfer.aToken[0], "cfile") ){
12301230
if( !isPush ){
@@ -1254,11 +1254,11 @@
12541254
nErr++;
12551255
break;
12561256
}
12571257
}else
12581258
1259
- /* gimme UUID
1259
+ /* gimme HASH
12601260
**
12611261
** Client is requesting a file. Send it.
12621262
*/
12631263
if( blob_eq(&xfer.aToken[0], "gimme")
12641264
&& xfer.nToken==2
@@ -1282,11 +1282,11 @@
12821282
&& blob_is_filename(&xfer.aToken[1])
12831283
){
12841284
send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0);
12851285
}else
12861286
1287
- /* igot UUID ?ISPRIVATE?
1287
+ /* igot HASH ?ISPRIVATE?
12881288
**
12891289
** Client announces that it has a particular file. If the ISPRIVATE
12901290
** argument exists and is non-zero, then the file is a private file.
12911291
*/
12921292
if( xfer.nToken>=2
@@ -2028,22 +2028,22 @@
20282028
lastPctDone = pctDone;
20292029
fflush(stdout);
20302030
}
20312031
}
20322032
2033
- /* file UUID SIZE \n CONTENT
2034
- ** file UUID DELTASRC SIZE \n CONTENT
2033
+ /* file HASH SIZE \n CONTENT
2034
+ ** file HASH DELTASRC SIZE \n CONTENT
20352035
**
20362036
** Receive a file transmitted from the server.
20372037
*/
20382038
if( blob_eq(&xfer.aToken[0],"file") ){
20392039
xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
20402040
nArtifactRcvd++;
20412041
}else
20422042
2043
- /* cfile UUID USIZE CSIZE \n CONTENT
2044
- ** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
2043
+ /* cfile HASH USIZE CSIZE \n CONTENT
2044
+ ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
20452045
**
20462046
** Receive a compressed file transmitted from the server.
20472047
*/
20482048
if( blob_eq(&xfer.aToken[0],"cfile") ){
20492049
xfer_accept_compressed_file(&xfer, 0, 0);
@@ -2062,11 +2062,11 @@
20622062
fossil_print("\rUnversioned-file received: %s\n",
20632063
blob_str(&xfer.aToken[1]));
20642064
}
20652065
}else
20662066
2067
- /* gimme UUID
2067
+ /* gimme HASH
20682068
**
20692069
** Server is requesting a file. If the file is a manifest, assume
20702070
** that the server will also want to know all of the content files
20712071
** associated with the manifest and send those too.
20722072
*/
@@ -2078,11 +2078,11 @@
20782078
int rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
20792079
if( rid ) send_file(&xfer, rid, &xfer.aToken[1], 0);
20802080
}
20812081
}else
20822082
2083
- /* igot UUID ?PRIVATEFLAG?
2083
+ /* igot HASH ?PRIVATEFLAG?
20842084
**
20852085
** Server announces that it has a particular file. If this is
20862086
** not a file that we have and we are pulling, then create a
20872087
** phantom to cause this file to be requested on the next cycle.
20882088
** Always remember that the server has this file so that we do
20892089
--- src/xfer.c
+++ src/xfer.c
@@ -54,11 +54,11 @@
54 time_t maxTime; /* Time when this transfer should be finished */
55 };
56
57
58 /*
59 ** The input blob contains a UUID. Convert it into a record ID.
60 ** Create a phantom record if no prior record exists and
61 ** phantomize is true.
62 **
63 ** Compare to uuid_to_rid(). This routine takes a blob argument
64 ** and does less error checking.
@@ -100,12 +100,12 @@
100 ** message. This routine finishes parsing that message and does
101 ** a record insert of the file.
102 **
103 ** The file line is in one of the following two forms:
104 **
105 ** file UUID SIZE \n CONTENT
106 ** file UUID DELTASRC SIZE \n CONTENT
107 **
108 ** The content is SIZE bytes immediately following the newline.
109 ** If DELTASRC exists, then the CONTENT is a delta against the
110 ** content of DELTASRC.
111 **
@@ -217,18 +217,18 @@
217 ** a record insert of the file. The difference between "file" and
218 ** "cfile" is that with "cfile" the content is already compressed.
219 **
220 ** The file line is in one of the following two forms:
221 **
222 ** cfile UUID USIZE CSIZE \n CONTENT
223 ** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
224 **
225 ** The content is CSIZE bytes immediately following the newline.
226 ** If DELTASRC exists, then the CONTENT is a delta against the
227 ** content of DELTASRC.
228 **
229 ** The original size of the UUID artifact is USIZE.
230 **
231 ** If any error occurs, write a message into pErr which has already
232 ** be initialized to an empty string.
233 **
234 ** Any artifact successfully received by this routine is considered to
@@ -415,11 +415,11 @@
415 static int send_delta_parent(
416 Xfer *pXfer, /* The transfer context */
417 int rid, /* record id of the file to send */
418 int isPrivate, /* True if rid is a private artifact */
419 Blob *pContent, /* The content of the file to send */
420 Blob *pUuid /* The UUID of the file to send */
421 ){
422 static const char *const azQuery[] = {
423 "SELECT pid FROM plink x"
424 " WHERE cid=%d"
425 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)",
@@ -469,11 +469,11 @@
469 */
470 static int send_delta_native(
471 Xfer *pXfer, /* The transfer context */
472 int rid, /* record id of the file to send */
473 int isPrivate, /* True if rid is a private artifact */
474 Blob *pUuid /* The UUID of the file to send */
475 ){
476 Blob src, delta;
477 int size = 0;
478 int srcId;
479
@@ -504,11 +504,11 @@
504 }
505
506 /*
507 ** Send the file identified by rid.
508 **
509 ** The pUuid can be NULL in which case the correct UUID is computed
510 ** from the rid.
511 **
512 ** Try to send the file as a native delta if nativeDelta is true, or
513 ** as a parent delta if nativeDelta is false.
514 **
@@ -1198,12 +1198,12 @@
1198 while( blob_line(xfer.pIn, &xfer.line) ){
1199 if( blob_buffer(&xfer.line)[0]=='#' ) continue;
1200 if( blob_size(&xfer.line)==0 ) continue;
1201 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
1202
1203 /* file UUID SIZE \n CONTENT
1204 ** file UUID DELTASRC SIZE \n CONTENT
1205 **
1206 ** Accept a file from the client.
1207 */
1208 if( blob_eq(&xfer.aToken[0], "file") ){
1209 if( !isPush ){
@@ -1219,12 +1219,12 @@
1219 nErr++;
1220 break;
1221 }
1222 }else
1223
1224 /* cfile UUID USIZE CSIZE \n CONTENT
1225 ** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
1226 **
1227 ** Accept a file from the client.
1228 */
1229 if( blob_eq(&xfer.aToken[0], "cfile") ){
1230 if( !isPush ){
@@ -1254,11 +1254,11 @@
1254 nErr++;
1255 break;
1256 }
1257 }else
1258
1259 /* gimme UUID
1260 **
1261 ** Client is requesting a file. Send it.
1262 */
1263 if( blob_eq(&xfer.aToken[0], "gimme")
1264 && xfer.nToken==2
@@ -1282,11 +1282,11 @@
1282 && blob_is_filename(&xfer.aToken[1])
1283 ){
1284 send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0);
1285 }else
1286
1287 /* igot UUID ?ISPRIVATE?
1288 **
1289 ** Client announces that it has a particular file. If the ISPRIVATE
1290 ** argument exists and is non-zero, then the file is a private file.
1291 */
1292 if( xfer.nToken>=2
@@ -2028,22 +2028,22 @@
2028 lastPctDone = pctDone;
2029 fflush(stdout);
2030 }
2031 }
2032
2033 /* file UUID SIZE \n CONTENT
2034 ** file UUID DELTASRC SIZE \n CONTENT
2035 **
2036 ** Receive a file transmitted from the server.
2037 */
2038 if( blob_eq(&xfer.aToken[0],"file") ){
2039 xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
2040 nArtifactRcvd++;
2041 }else
2042
2043 /* cfile UUID USIZE CSIZE \n CONTENT
2044 ** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
2045 **
2046 ** Receive a compressed file transmitted from the server.
2047 */
2048 if( blob_eq(&xfer.aToken[0],"cfile") ){
2049 xfer_accept_compressed_file(&xfer, 0, 0);
@@ -2062,11 +2062,11 @@
2062 fossil_print("\rUnversioned-file received: %s\n",
2063 blob_str(&xfer.aToken[1]));
2064 }
2065 }else
2066
2067 /* gimme UUID
2068 **
2069 ** Server is requesting a file. If the file is a manifest, assume
2070 ** that the server will also want to know all of the content files
2071 ** associated with the manifest and send those too.
2072 */
@@ -2078,11 +2078,11 @@
2078 int rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
2079 if( rid ) send_file(&xfer, rid, &xfer.aToken[1], 0);
2080 }
2081 }else
2082
2083 /* igot UUID ?PRIVATEFLAG?
2084 **
2085 ** Server announces that it has a particular file. If this is
2086 ** not a file that we have and we are pulling, then create a
2087 ** phantom to cause this file to be requested on the next cycle.
2088 ** Always remember that the server has this file so that we do
2089
--- src/xfer.c
+++ src/xfer.c
@@ -54,11 +54,11 @@
54 time_t maxTime; /* Time when this transfer should be finished */
55 };
56
57
58 /*
59 ** The input blob contains an artifact. Convert it into a record ID.
60 ** Create a phantom record if no prior record exists and
61 ** phantomize is true.
62 **
63 ** Compare to uuid_to_rid(). This routine takes a blob argument
64 ** and does less error checking.
@@ -100,12 +100,12 @@
100 ** message. This routine finishes parsing that message and does
101 ** a record insert of the file.
102 **
103 ** The file line is in one of the following two forms:
104 **
105 ** file HASH SIZE \n CONTENT
106 ** file HASH DELTASRC SIZE \n CONTENT
107 **
108 ** The content is SIZE bytes immediately following the newline.
109 ** If DELTASRC exists, then the CONTENT is a delta against the
110 ** content of DELTASRC.
111 **
@@ -217,18 +217,18 @@
217 ** a record insert of the file. The difference between "file" and
218 ** "cfile" is that with "cfile" the content is already compressed.
219 **
220 ** The file line is in one of the following two forms:
221 **
222 ** cfile HASH USIZE CSIZE \n CONTENT
223 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
224 **
225 ** The content is CSIZE bytes immediately following the newline.
226 ** If DELTASRC exists, then the CONTENT is a delta against the
227 ** content of DELTASRC.
228 **
229 ** The original size of the HASH artifact is USIZE.
230 **
231 ** If any error occurs, write a message into pErr which has already
232 ** be initialized to an empty string.
233 **
234 ** Any artifact successfully received by this routine is considered to
@@ -415,11 +415,11 @@
415 static int send_delta_parent(
416 Xfer *pXfer, /* The transfer context */
417 int rid, /* record id of the file to send */
418 int isPrivate, /* True if rid is a private artifact */
419 Blob *pContent, /* The content of the file to send */
420 Blob *pUuid /* The HASH of the file to send */
421 ){
422 static const char *const azQuery[] = {
423 "SELECT pid FROM plink x"
424 " WHERE cid=%d"
425 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)",
@@ -469,11 +469,11 @@
469 */
470 static int send_delta_native(
471 Xfer *pXfer, /* The transfer context */
472 int rid, /* record id of the file to send */
473 int isPrivate, /* True if rid is a private artifact */
474 Blob *pUuid /* The HASH of the file to send */
475 ){
476 Blob src, delta;
477 int size = 0;
478 int srcId;
479
@@ -504,11 +504,11 @@
504 }
505
506 /*
507 ** Send the file identified by rid.
508 **
509 ** The pUuid can be NULL in which case the correct hash is computed
510 ** from the rid.
511 **
512 ** Try to send the file as a native delta if nativeDelta is true, or
513 ** as a parent delta if nativeDelta is false.
514 **
@@ -1198,12 +1198,12 @@
1198 while( blob_line(xfer.pIn, &xfer.line) ){
1199 if( blob_buffer(&xfer.line)[0]=='#' ) continue;
1200 if( blob_size(&xfer.line)==0 ) continue;
1201 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
1202
1203 /* file HASH SIZE \n CONTENT
1204 ** file HASH DELTASRC SIZE \n CONTENT
1205 **
1206 ** Accept a file from the client.
1207 */
1208 if( blob_eq(&xfer.aToken[0], "file") ){
1209 if( !isPush ){
@@ -1219,12 +1219,12 @@
1219 nErr++;
1220 break;
1221 }
1222 }else
1223
1224 /* cfile HASH USIZE CSIZE \n CONTENT
1225 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
1226 **
1227 ** Accept a file from the client.
1228 */
1229 if( blob_eq(&xfer.aToken[0], "cfile") ){
1230 if( !isPush ){
@@ -1254,11 +1254,11 @@
1254 nErr++;
1255 break;
1256 }
1257 }else
1258
1259 /* gimme HASH
1260 **
1261 ** Client is requesting a file. Send it.
1262 */
1263 if( blob_eq(&xfer.aToken[0], "gimme")
1264 && xfer.nToken==2
@@ -1282,11 +1282,11 @@
1282 && blob_is_filename(&xfer.aToken[1])
1283 ){
1284 send_unversioned_file(&xfer, blob_str(&xfer.aToken[1]), 0);
1285 }else
1286
1287 /* igot HASH ?ISPRIVATE?
1288 **
1289 ** Client announces that it has a particular file. If the ISPRIVATE
1290 ** argument exists and is non-zero, then the file is a private file.
1291 */
1292 if( xfer.nToken>=2
@@ -2028,22 +2028,22 @@
2028 lastPctDone = pctDone;
2029 fflush(stdout);
2030 }
2031 }
2032
2033 /* file HASH SIZE \n CONTENT
2034 ** file HASH DELTASRC SIZE \n CONTENT
2035 **
2036 ** Receive a file transmitted from the server.
2037 */
2038 if( blob_eq(&xfer.aToken[0],"file") ){
2039 xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
2040 nArtifactRcvd++;
2041 }else
2042
2043 /* cfile HASH USIZE CSIZE \n CONTENT
2044 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
2045 **
2046 ** Receive a compressed file transmitted from the server.
2047 */
2048 if( blob_eq(&xfer.aToken[0],"cfile") ){
2049 xfer_accept_compressed_file(&xfer, 0, 0);
@@ -2062,11 +2062,11 @@
2062 fossil_print("\rUnversioned-file received: %s\n",
2063 blob_str(&xfer.aToken[1]));
2064 }
2065 }else
2066
2067 /* gimme HASH
2068 **
2069 ** Server is requesting a file. If the file is a manifest, assume
2070 ** that the server will also want to know all of the content files
2071 ** associated with the manifest and send those too.
2072 */
@@ -2078,11 +2078,11 @@
2078 int rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
2079 if( rid ) send_file(&xfer, rid, &xfer.aToken[1], 0);
2080 }
2081 }else
2082
2083 /* igot HASH ?PRIVATEFLAG?
2084 **
2085 ** Server announces that it has a particular file. If this is
2086 ** not a file that we have and we are pulling, then create a
2087 ** phantom to cause this file to be requested on the next cycle.
2088 ** Always remember that the server has this file so that we do
2089

Keyboard Shortcuts

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