Fossil SCM

Refactoring and cleanup of some of the hash name interfaces.

drh 2017-02-28 16:25 fossil-2.0
Commit 1c8768b0deed45e9afc9de3e42a8ce1d220a03ff
+6 -1
--- src/blob.c
+++ src/blob.c
@@ -648,13 +648,18 @@
648648
pFrom->iCursor = i;
649649
}
650650
651651
/*
652652
** Return true if the blob contains a valid base16 identifier artifact hash.
653
+**
654
+** The value returned is actually one of HNAME_SHA1 OR HNAME_K256 if the
655
+** hash is valid. Both of these are non-zero and therefore "true".
656
+** If the hash is not valid, then HNAME_ERROR is returned, which is zero or
657
+** false.
653658
*/
654659
int blob_is_hname(Blob *pBlob){
655
- return hname_validate(blob_buffer(pBlob), blob_size(pBlob))!=HNAME_NONE;
660
+ return hname_validate(blob_buffer(pBlob), blob_size(pBlob));
656661
}
657662
658663
/*
659664
** Return true if the blob contains a valid filename
660665
*/
661666
--- src/blob.c
+++ src/blob.c
@@ -648,13 +648,18 @@
648 pFrom->iCursor = i;
649 }
650
651 /*
652 ** Return true if the blob contains a valid base16 identifier artifact hash.
 
 
 
 
 
653 */
654 int blob_is_hname(Blob *pBlob){
655 return hname_validate(blob_buffer(pBlob), blob_size(pBlob))!=HNAME_NONE;
656 }
657
658 /*
659 ** Return true if the blob contains a valid filename
660 */
661
--- src/blob.c
+++ src/blob.c
@@ -648,13 +648,18 @@
648 pFrom->iCursor = i;
649 }
650
651 /*
652 ** Return true if the blob contains a valid base16 identifier artifact hash.
653 **
654 ** The value returned is actually one of HNAME_SHA1 OR HNAME_K256 if the
655 ** hash is valid. Both of these are non-zero and therefore "true".
656 ** If the hash is not valid, then HNAME_ERROR is returned, which is zero or
657 ** false.
658 */
659 int blob_is_hname(Blob *pBlob){
660 return hname_validate(blob_buffer(pBlob), blob_size(pBlob));
661 }
662
663 /*
664 ** Return true if the blob contains a valid filename
665 */
666
+1 -1
--- src/browse.c
+++ src/browse.c
@@ -368,11 +368,11 @@
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 += HNAME_LEN_MAX+1;
373
+ if( zUuid!=0 && zPath[i]==0 ) nByte += HNAME_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
--- src/browse.c
+++ src/browse.c
@@ -368,11 +368,11 @@
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
--- src/browse.c
+++ src/browse.c
@@ -368,11 +368,11 @@
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_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
+4 -3
--- src/bundle.c
+++ src/bundle.c
@@ -447,11 +447,11 @@
447447
db_column_blob(&q, 0, &h1);
448448
blob_zero(&c1);
449449
db_column_blob(&q, 1, &c1);
450450
blob_uncompress(&c1, &c1);
451451
blob_zero(&c2);
452
- if( db_column_type(&q,2)==SQLITE_TEXT && db_column_bytes(&q,2)==40 ){
452
+ if( db_column_type(&q,2)==SQLITE_TEXT && db_column_bytes(&q,2)>=HNAME_MIN ){
453453
Blob basis;
454454
rid = db_int(0,"SELECT rid FROM blob WHERE uuid=%Q",
455455
db_column_text(&q,2));
456456
content_get(rid, &basis);
457457
blob_delta_apply(&basis, &c1, &c2);
@@ -597,12 +597,13 @@
597597
** repo, then the delta encodings cannot be decoded and the bundle cannot
598598
** be extracted. */
599599
zMissingDeltas = db_text(0,
600600
"SELECT group_concat(substr(delta,1,10),' ')"
601601
" FROM bblob"
602
- " WHERE typeof(delta)='text' AND length(delta)=40"
603
- " AND NOT EXISTS(SELECT 1 FROM blob WHERE uuid=bblob.delta)");
602
+ " WHERE typeof(delta)='text' AND length(delta)>=%d"
603
+ " AND NOT EXISTS(SELECT 1 FROM blob WHERE uuid=bblob.delta)",
604
+ HNAME_MIN);
604605
if( zMissingDeltas && zMissingDeltas[0] ){
605606
fossil_fatal("delta basis artifacts not found in repository: %s",
606607
zMissingDeltas);
607608
}
608609
609610
--- src/bundle.c
+++ src/bundle.c
@@ -447,11 +447,11 @@
447 db_column_blob(&q, 0, &h1);
448 blob_zero(&c1);
449 db_column_blob(&q, 1, &c1);
450 blob_uncompress(&c1, &c1);
451 blob_zero(&c2);
452 if( db_column_type(&q,2)==SQLITE_TEXT && db_column_bytes(&q,2)==40 ){
453 Blob basis;
454 rid = db_int(0,"SELECT rid FROM blob WHERE uuid=%Q",
455 db_column_text(&q,2));
456 content_get(rid, &basis);
457 blob_delta_apply(&basis, &c1, &c2);
@@ -597,12 +597,13 @@
597 ** repo, then the delta encodings cannot be decoded and the bundle cannot
598 ** be extracted. */
599 zMissingDeltas = db_text(0,
600 "SELECT group_concat(substr(delta,1,10),' ')"
601 " FROM bblob"
602 " WHERE typeof(delta)='text' AND length(delta)=40"
603 " AND NOT EXISTS(SELECT 1 FROM blob WHERE uuid=bblob.delta)");
 
604 if( zMissingDeltas && zMissingDeltas[0] ){
605 fossil_fatal("delta basis artifacts not found in repository: %s",
606 zMissingDeltas);
607 }
608
609
--- src/bundle.c
+++ src/bundle.c
@@ -447,11 +447,11 @@
447 db_column_blob(&q, 0, &h1);
448 blob_zero(&c1);
449 db_column_blob(&q, 1, &c1);
450 blob_uncompress(&c1, &c1);
451 blob_zero(&c2);
452 if( db_column_type(&q,2)==SQLITE_TEXT && db_column_bytes(&q,2)>=HNAME_MIN ){
453 Blob basis;
454 rid = db_int(0,"SELECT rid FROM blob WHERE uuid=%Q",
455 db_column_text(&q,2));
456 content_get(rid, &basis);
457 blob_delta_apply(&basis, &c1, &c2);
@@ -597,12 +597,13 @@
597 ** repo, then the delta encodings cannot be decoded and the bundle cannot
598 ** be extracted. */
599 zMissingDeltas = db_text(0,
600 "SELECT group_concat(substr(delta,1,10),' ')"
601 " FROM bblob"
602 " WHERE typeof(delta)='text' AND length(delta)>=%d"
603 " AND NOT EXISTS(SELECT 1 FROM blob WHERE uuid=bblob.delta)",
604 HNAME_MIN);
605 if( zMissingDeltas && zMissingDeltas[0] ){
606 fossil_fatal("delta basis artifacts not found in repository: %s",
607 zMissingDeltas);
608 }
609
610
+2 -2
--- src/db.c
+++ src/db.c
@@ -2080,13 +2080,13 @@
20802080
** email address will contain a "@" character and "@" is not valid within
20812081
** an SHA1 hash so there is no chance that a valid email address will go
20822082
** unconcealed.
20832083
*/
20842084
char *db_conceal(const char *zContent, int n){
2085
- static char zHash[HNAME_LEN_MAX+1];
2085
+ static char zHash[HNAME_MAX+1];
20862086
Blob out;
2087
- if( hname_validate(zContent, n)!=HNAME_NONE ){
2087
+ if( hname_validate(zContent, n) ){
20882088
memcpy(zHash, zContent, n);
20892089
zHash[n] = 0;
20902090
}else{
20912091
sha1sum_step_text(zContent, n);
20922092
sha1sum_finish(&out);
20932093
--- src/db.c
+++ src/db.c
@@ -2080,13 +2080,13 @@
2080 ** email address will contain a "@" character and "@" is not valid within
2081 ** an SHA1 hash so there is no chance that a valid email address will go
2082 ** unconcealed.
2083 */
2084 char *db_conceal(const char *zContent, int n){
2085 static char zHash[HNAME_LEN_MAX+1];
2086 Blob out;
2087 if( hname_validate(zContent, n)!=HNAME_NONE ){
2088 memcpy(zHash, zContent, n);
2089 zHash[n] = 0;
2090 }else{
2091 sha1sum_step_text(zContent, n);
2092 sha1sum_finish(&out);
2093
--- src/db.c
+++ src/db.c
@@ -2080,13 +2080,13 @@
2080 ** email address will contain a "@" character and "@" is not valid within
2081 ** an SHA1 hash so there is no chance that a valid email address will go
2082 ** unconcealed.
2083 */
2084 char *db_conceal(const char *zContent, int n){
2085 static char zHash[HNAME_MAX+1];
2086 Blob out;
2087 if( hname_validate(zContent, n) ){
2088 memcpy(zHash, zContent, n);
2089 zHash[n] = 0;
2090 }else{
2091 sha1sum_step_text(zContent, n);
2092 sha1sum_finish(&out);
2093
+1 -1
--- src/event.c
+++ src/event.c
@@ -384,11 +384,11 @@
384384
rid = db_int(0,
385385
"SELECT rid FROM tagxref"
386386
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname GLOB '%q*')"
387387
" ORDER BY mtime DESC", zTag
388388
);
389
- if( rid && strlen(zId)<40 ){
389
+ if( rid && strlen(zId)<HNAME_MIN ){
390390
zId = db_text(0,
391391
"SELECT substr(tagname,7) FROM tag WHERE tagname GLOB '%q*'",
392392
zTag
393393
);
394394
}
395395
--- src/event.c
+++ src/event.c
@@ -384,11 +384,11 @@
384 rid = db_int(0,
385 "SELECT rid FROM tagxref"
386 " WHERE tagid=(SELECT tagid FROM tag WHERE tagname GLOB '%q*')"
387 " ORDER BY mtime DESC", zTag
388 );
389 if( rid && strlen(zId)<40 ){
390 zId = db_text(0,
391 "SELECT substr(tagname,7) FROM tag WHERE tagname GLOB '%q*'",
392 zTag
393 );
394 }
395
--- src/event.c
+++ src/event.c
@@ -384,11 +384,11 @@
384 rid = db_int(0,
385 "SELECT rid FROM tagxref"
386 " WHERE tagid=(SELECT tagid FROM tag WHERE tagname GLOB '%q*')"
387 " ORDER BY mtime DESC", zTag
388 );
389 if( rid && strlen(zId)<HNAME_MIN ){
390 zId = db_text(0,
391 "SELECT substr(tagname,7) FROM tag WHERE tagname GLOB '%q*'",
392 zTag
393 );
394 }
395
+12 -13
--- src/hname.c
+++ src/hname.c
@@ -26,20 +26,20 @@
2626
2727
#if INTERFACE
2828
/*
2929
** Code numbers for the allowed hash algorithms.
3030
*/
31
-#define HNAME_NONE (-1) /* Not a valid hash */
32
-#define HNAME_SHA1 0 /* SHA1 */
33
-#define HNAME_K224 1 /* SHA3-224 */
34
-#define HNAME_K256 2 /* SHA3-256 */
31
+#define HNAME_ERROR 0 /* Not a valid hash */
32
+#define HNAME_SHA1 1 /* SHA1 */
33
+#define HNAME_K224 2 /* SHA3-224 */
34
+#define HNAME_K256 3 /* SHA3-256 */
3535
3636
/*
3737
** Minimum and maximum lengths for a hash value when hex encoded.
3838
*/
39
-#define HNAME_LEN_MIN 40 /* Length for SHA1 */
40
-#define HNAME_LEN_MAX 64 /* Length for SHA3-256 */
39
+#define HNAME_MIN 40 /* Length for SHA1 */
40
+#define HNAME_MAX 64 /* Length for SHA3-256 */
4141
4242
/*
4343
** Hash lengths for the various algorithms
4444
*/
4545
#define HNAME_LEN_SHA1 40
@@ -52,36 +52,35 @@
5252
/*
5353
** Convert a hash algorithm code number into a string name for that algorithm.
5454
*/
5555
const char *hname_algname(int aid){
5656
if( aid==HNAME_K224 ) return "SHA3-224";
57
- if( aid==HNAME_K256 ) return "SHA3-256";
5857
return "SHA1";
5958
}
6059
6160
/*
62
-** Given a hash algorithm name, return its appropriate number. Return -1
63
-** if the name is unknown.
61
+** Given a hash algorithm name, return its appropriate number. Return
62
+** HNAME_ERROR if the name is unknown.
6463
*/
6564
int hname_algid(const char *zName){
6665
if( fossil_stricmp(zName,"sha1")==0 ) return HNAME_SHA1;
6766
if( fossil_stricmp(zName,"sha3-224")==0 ) return HNAME_K224;
6867
if( fossil_stricmp(zName,"sha3-256")==0 ) return HNAME_K256;
69
- return -1;
68
+ return HNAME_ERROR;
7069
}
7170
7271
/*
7372
** Return the integer hash algorithm code number (ex: HNAME_K224) for
74
-** the hash string provided. Or return HNAME_NONE if the input string
73
+** the hash string provided. Or return HNAME_ERROR (0) if the input string
7574
** is not a valid artifact hash string.
7675
*/
7776
int hname_validate(const char *zHash, int nHash){
7877
int id;
7978
switch( nHash ){
8079
case HNAME_LEN_SHA1: id = HNAME_SHA1; break;
8180
case HNAME_LEN_K224: id = HNAME_K224; break;
8281
case HNAME_LEN_K256: id = HNAME_K256; break;
83
- default: return HNAME_NONE;
82
+ default: return HNAME_ERROR;
8483
}
85
- if( !validate16(zHash, nHash) ) return HNAME_NONE;
84
+ if( !validate16(zHash, nHash) ) return HNAME_ERROR;
8685
return id;
8786
}
8887
--- src/hname.c
+++ src/hname.c
@@ -26,20 +26,20 @@
26
27 #if INTERFACE
28 /*
29 ** Code numbers for the allowed hash algorithms.
30 */
31 #define HNAME_NONE (-1) /* Not a valid hash */
32 #define HNAME_SHA1 0 /* SHA1 */
33 #define HNAME_K224 1 /* SHA3-224 */
34 #define HNAME_K256 2 /* SHA3-256 */
35
36 /*
37 ** Minimum and maximum lengths for a hash value when hex encoded.
38 */
39 #define HNAME_LEN_MIN 40 /* Length for SHA1 */
40 #define HNAME_LEN_MAX 64 /* Length for SHA3-256 */
41
42 /*
43 ** Hash lengths for the various algorithms
44 */
45 #define HNAME_LEN_SHA1 40
@@ -52,36 +52,35 @@
52 /*
53 ** Convert a hash algorithm code number into a string name for that algorithm.
54 */
55 const char *hname_algname(int aid){
56 if( aid==HNAME_K224 ) return "SHA3-224";
57 if( aid==HNAME_K256 ) return "SHA3-256";
58 return "SHA1";
59 }
60
61 /*
62 ** Given a hash algorithm name, return its appropriate number. Return -1
63 ** if the name is unknown.
64 */
65 int hname_algid(const char *zName){
66 if( fossil_stricmp(zName,"sha1")==0 ) return HNAME_SHA1;
67 if( fossil_stricmp(zName,"sha3-224")==0 ) return HNAME_K224;
68 if( fossil_stricmp(zName,"sha3-256")==0 ) return HNAME_K256;
69 return -1;
70 }
71
72 /*
73 ** Return the integer hash algorithm code number (ex: HNAME_K224) for
74 ** the hash string provided. Or return HNAME_NONE if the input string
75 ** is not a valid artifact hash string.
76 */
77 int hname_validate(const char *zHash, int nHash){
78 int id;
79 switch( nHash ){
80 case HNAME_LEN_SHA1: id = HNAME_SHA1; break;
81 case HNAME_LEN_K224: id = HNAME_K224; break;
82 case HNAME_LEN_K256: id = HNAME_K256; break;
83 default: return HNAME_NONE;
84 }
85 if( !validate16(zHash, nHash) ) return HNAME_NONE;
86 return id;
87 }
88
--- src/hname.c
+++ src/hname.c
@@ -26,20 +26,20 @@
26
27 #if INTERFACE
28 /*
29 ** Code numbers for the allowed hash algorithms.
30 */
31 #define HNAME_ERROR 0 /* Not a valid hash */
32 #define HNAME_SHA1 1 /* SHA1 */
33 #define HNAME_K224 2 /* SHA3-224 */
34 #define HNAME_K256 3 /* SHA3-256 */
35
36 /*
37 ** Minimum and maximum lengths for a hash value when hex encoded.
38 */
39 #define HNAME_MIN 40 /* Length for SHA1 */
40 #define HNAME_MAX 64 /* Length for SHA3-256 */
41
42 /*
43 ** Hash lengths for the various algorithms
44 */
45 #define HNAME_LEN_SHA1 40
@@ -52,36 +52,35 @@
52 /*
53 ** Convert a hash algorithm code number into a string name for that algorithm.
54 */
55 const char *hname_algname(int aid){
56 if( aid==HNAME_K224 ) return "SHA3-224";
 
57 return "SHA1";
58 }
59
60 /*
61 ** Given a hash algorithm name, return its appropriate number. Return
62 ** HNAME_ERROR if the name is unknown.
63 */
64 int hname_algid(const char *zName){
65 if( fossil_stricmp(zName,"sha1")==0 ) return HNAME_SHA1;
66 if( fossil_stricmp(zName,"sha3-224")==0 ) return HNAME_K224;
67 if( fossil_stricmp(zName,"sha3-256")==0 ) return HNAME_K256;
68 return HNAME_ERROR;
69 }
70
71 /*
72 ** Return the integer hash algorithm code number (ex: HNAME_K224) for
73 ** the hash string provided. Or return HNAME_ERROR (0) if the input string
74 ** is not a valid artifact hash string.
75 */
76 int hname_validate(const char *zHash, int nHash){
77 int id;
78 switch( nHash ){
79 case HNAME_LEN_SHA1: id = HNAME_SHA1; break;
80 case HNAME_LEN_K224: id = HNAME_K224; break;
81 case HNAME_LEN_K256: id = HNAME_K256; break;
82 default: return HNAME_ERROR;
83 }
84 if( !validate16(zHash, nHash) ) return HNAME_ERROR;
85 return id;
86 }
87
+13 -13
--- src/manifest.c
+++ src/manifest.c
@@ -449,15 +449,15 @@
449449
defossilize(zName);
450450
if( !file_is_simple_pathname(zName, 0) ){
451451
SYNTAX("invalid filename on A-card");
452452
}
453453
defossilize(zTarget);
454
- if( hname_validate(zTarget,nTarget)==HNAME_NONE
454
+ if( !hname_validate(zTarget,nTarget)
455455
&& !wiki_name_is_wellformed((const unsigned char *)zTarget) ){
456456
SYNTAX("invalid target on A-card");
457457
}
458
- if( zSrc && hname_validate(zSrc,nSrc)==HNAME_NONE ){
458
+ if( zSrc && !hname_validate(zSrc,nSrc) ){
459459
SYNTAX("invalid source on A-card");
460460
}
461461
p->zAttachName = (char*)file_tail(zName);
462462
p->zAttachSrc = zSrc;
463463
p->zAttachTarget = zTarget;
@@ -471,11 +471,11 @@
471471
*/
472472
case 'B': {
473473
if( p->zBaseline ) SYNTAX("more than one B-card");
474474
p->zBaseline = next_token(&x, &sz);
475475
if( p->zBaseline==0 ) SYNTAX("missing hash on B-card");
476
- if( hname_validate(p->zBaseline,sz)==HNAME_NONE ){
476
+ if( !hname_validate(p->zBaseline,sz) ){
477477
SYNTAX("invalid hash on B-card");
478478
}
479479
break;
480480
}
481481
@@ -522,11 +522,11 @@
522522
case 'E': {
523523
if( p->rEventDate>0.0 ) SYNTAX("more than one E-card");
524524
p->rEventDate = db_double(0.0,"SELECT julianday(%Q)", next_token(&x,0));
525525
if( p->rEventDate<=0.0 ) SYNTAX("malformed date on E-card");
526526
p->zEventId = next_token(&x, &sz);
527
- if( hname_validate(p->zEventId, sz)==HNAME_NONE ){
527
+ if( !hname_validate(p->zEventId, sz) ){
528528
SYNTAX("malformed hash on E-card");
529529
}
530530
break;
531531
}
532532
@@ -545,11 +545,11 @@
545545
if( !file_is_simple_pathname(zName, 0) ){
546546
SYNTAX("F-card filename is not a simple path");
547547
}
548548
zUuid = next_token(&x, &sz);
549549
if( p->zBaseline==0 || zUuid!=0 ){
550
- if( hname_validate(zUuid,sz)==HNAME_NONE ){
550
+ if( !hname_validate(zUuid,sz) ){
551551
SYNTAX("F-card hash invalid");
552552
}
553553
}
554554
zPerm = next_token(&x,0);
555555
zPriorName = next_token(&x,0);
@@ -645,11 +645,11 @@
645645
** occur in clusters only.
646646
*/
647647
case 'M': {
648648
zUuid = next_token(&x, &sz);
649649
if( zUuid==0 ) SYNTAX("missing hash on M-card");
650
- if( hname_validate(zUuid,sz)==HNAME_NONE ){
650
+ if( !hname_validate(zUuid,sz) ){
651651
SYNTAX("Invalid hash on M-card");
652652
}
653653
if( p->nCChild>=p->nCChildAlloc ){
654654
p->nCChildAlloc = p->nCChildAlloc*2 + 10;
655655
p->azCChild = fossil_realloc(p->azCChild
@@ -685,11 +685,11 @@
685685
** check-in historically has an empty P-card, so empty P-cards
686686
** must be accepted.
687687
*/
688688
case 'P': {
689689
while( (zUuid = next_token(&x, &sz))!=0 ){
690
- if( hname_validate(zUuid, sz)==HNAME_NONE ){
690
+ if( !hname_validate(zUuid, sz) ){
691691
SYNTAX("invalid hash on P-card");
692692
}
693693
if( p->nParent>=p->nParentAlloc ){
694694
p->nParentAlloc = p->nParentAlloc*2 + 5;
695695
p->azParent = fossil_realloc(p->azParent,
@@ -710,20 +710,20 @@
710710
case 'Q': {
711711
if( (zUuid=next_token(&x, &sz))==0 ) SYNTAX("missing hash on Q-card");
712712
if( zUuid[0]!='+' && zUuid[0]!='-' ){
713713
SYNTAX("Q-card does not begin with '+' or '-'");
714714
}
715
- if( hname_validate(&zUuid[1], sz-1)==HNAME_NONE ){
715
+ if( !hname_validate(&zUuid[1], sz-1) ){
716716
SYNTAX("invalid hash on Q-card");
717717
}
718718
n = p->nCherrypick;
719719
p->nCherrypick++;
720720
p->aCherrypick = fossil_realloc(p->aCherrypick,
721721
p->nCherrypick*sizeof(p->aCherrypick[0]));
722722
p->aCherrypick[n].zCPTarget = zUuid;
723723
p->aCherrypick[n].zCPBase = zUuid = next_token(&x, &sz);
724
- if( zUuid && hname_validate(zUuid,sz)==HNAME_NONE ){
724
+ if( zUuid && !hname_validate(zUuid,sz) ){
725725
SYNTAX("invalid second hash on Q-card");
726726
}
727727
break;
728728
}
729729
@@ -762,11 +762,11 @@
762762
if( zName==0 ) SYNTAX("missing name on T-card");
763763
zUuid = next_token(&x, &sz);
764764
if( zUuid==0 ) SYNTAX("missing artifact hash on T-card");
765765
zValue = next_token(&x, 0);
766766
if( zValue ) defossilize(zValue);
767
- if( hname_validate(zUuid, sz)!=HNAME_NONE ){
767
+ if( hname_validate(zUuid, sz) ){
768768
/* A valid artifact hash */
769769
if( p->zEventId ) SYNTAX("non-self-referential T-card in event");
770770
}else if( sz==1 && zUuid[0]=='*' ){
771771
zUuid = 0;
772772
hasSelfRefTag = 1;
@@ -1620,21 +1620,21 @@
16201620
char *zCopy = 0;
16211621
char **azParent = 0;
16221622
Manifest *p = 0;
16231623
int i, j;
16241624
int n = (int)strlen(zValue);
1625
- int mxParent = (n+1)/(HNAME_LEN_MIN+1);
1625
+ int mxParent = (n+1)/(HNAME_MIN+1);
16261626
16271627
if( mxParent<1 ) return;
16281628
zCopy = fossil_strdup(zValue);
16291629
azParent = fossil_malloc( sizeof(azParent[0])*mxParent );
16301630
for(nParent=0, i=0; zCopy[i]; i++){
16311631
char *z = &zCopy[i];
16321632
azParent[nParent++] = z;
16331633
if( nParent>mxParent ) goto reparent_abort;
1634
- for(j=HNAME_LEN_MIN; z[j]>' '; j++){}
1635
- if( hname_validate(z, j)==HNAME_NONE ) goto reparent_abort;
1634
+ for(j=HNAME_MIN; z[j]>' '; j++){}
1635
+ if( !hname_validate(z, j) ) goto reparent_abort;
16361636
if( z[j]==0 ) break;
16371637
z[j] = 0;
16381638
i += j;
16391639
}
16401640
if( !db_exists("SELECT 1 FROM plink WHERE cid=%d AND pid=%d",
16411641
--- src/manifest.c
+++ src/manifest.c
@@ -449,15 +449,15 @@
449 defossilize(zName);
450 if( !file_is_simple_pathname(zName, 0) ){
451 SYNTAX("invalid filename on A-card");
452 }
453 defossilize(zTarget);
454 if( hname_validate(zTarget,nTarget)==HNAME_NONE
455 && !wiki_name_is_wellformed((const unsigned char *)zTarget) ){
456 SYNTAX("invalid target on A-card");
457 }
458 if( zSrc && hname_validate(zSrc,nSrc)==HNAME_NONE ){
459 SYNTAX("invalid source on A-card");
460 }
461 p->zAttachName = (char*)file_tail(zName);
462 p->zAttachSrc = zSrc;
463 p->zAttachTarget = zTarget;
@@ -471,11 +471,11 @@
471 */
472 case 'B': {
473 if( p->zBaseline ) SYNTAX("more than one B-card");
474 p->zBaseline = next_token(&x, &sz);
475 if( p->zBaseline==0 ) SYNTAX("missing hash on B-card");
476 if( hname_validate(p->zBaseline,sz)==HNAME_NONE ){
477 SYNTAX("invalid hash on B-card");
478 }
479 break;
480 }
481
@@ -522,11 +522,11 @@
522 case 'E': {
523 if( p->rEventDate>0.0 ) SYNTAX("more than one E-card");
524 p->rEventDate = db_double(0.0,"SELECT julianday(%Q)", next_token(&x,0));
525 if( p->rEventDate<=0.0 ) SYNTAX("malformed date on E-card");
526 p->zEventId = next_token(&x, &sz);
527 if( hname_validate(p->zEventId, sz)==HNAME_NONE ){
528 SYNTAX("malformed hash on E-card");
529 }
530 break;
531 }
532
@@ -545,11 +545,11 @@
545 if( !file_is_simple_pathname(zName, 0) ){
546 SYNTAX("F-card filename is not a simple path");
547 }
548 zUuid = next_token(&x, &sz);
549 if( p->zBaseline==0 || zUuid!=0 ){
550 if( hname_validate(zUuid,sz)==HNAME_NONE ){
551 SYNTAX("F-card hash invalid");
552 }
553 }
554 zPerm = next_token(&x,0);
555 zPriorName = next_token(&x,0);
@@ -645,11 +645,11 @@
645 ** occur in clusters only.
646 */
647 case 'M': {
648 zUuid = next_token(&x, &sz);
649 if( zUuid==0 ) SYNTAX("missing hash on M-card");
650 if( hname_validate(zUuid,sz)==HNAME_NONE ){
651 SYNTAX("Invalid hash on M-card");
652 }
653 if( p->nCChild>=p->nCChildAlloc ){
654 p->nCChildAlloc = p->nCChildAlloc*2 + 10;
655 p->azCChild = fossil_realloc(p->azCChild
@@ -685,11 +685,11 @@
685 ** check-in historically has an empty P-card, so empty P-cards
686 ** must be accepted.
687 */
688 case 'P': {
689 while( (zUuid = next_token(&x, &sz))!=0 ){
690 if( hname_validate(zUuid, sz)==HNAME_NONE ){
691 SYNTAX("invalid hash on P-card");
692 }
693 if( p->nParent>=p->nParentAlloc ){
694 p->nParentAlloc = p->nParentAlloc*2 + 5;
695 p->azParent = fossil_realloc(p->azParent,
@@ -710,20 +710,20 @@
710 case 'Q': {
711 if( (zUuid=next_token(&x, &sz))==0 ) SYNTAX("missing hash on Q-card");
712 if( zUuid[0]!='+' && zUuid[0]!='-' ){
713 SYNTAX("Q-card does not begin with '+' or '-'");
714 }
715 if( hname_validate(&zUuid[1], sz-1)==HNAME_NONE ){
716 SYNTAX("invalid hash on Q-card");
717 }
718 n = p->nCherrypick;
719 p->nCherrypick++;
720 p->aCherrypick = fossil_realloc(p->aCherrypick,
721 p->nCherrypick*sizeof(p->aCherrypick[0]));
722 p->aCherrypick[n].zCPTarget = zUuid;
723 p->aCherrypick[n].zCPBase = zUuid = next_token(&x, &sz);
724 if( zUuid && hname_validate(zUuid,sz)==HNAME_NONE ){
725 SYNTAX("invalid second hash on Q-card");
726 }
727 break;
728 }
729
@@ -762,11 +762,11 @@
762 if( zName==0 ) SYNTAX("missing name on T-card");
763 zUuid = next_token(&x, &sz);
764 if( zUuid==0 ) SYNTAX("missing artifact hash on T-card");
765 zValue = next_token(&x, 0);
766 if( zValue ) defossilize(zValue);
767 if( hname_validate(zUuid, sz)!=HNAME_NONE ){
768 /* A valid artifact hash */
769 if( p->zEventId ) SYNTAX("non-self-referential T-card in event");
770 }else if( sz==1 && zUuid[0]=='*' ){
771 zUuid = 0;
772 hasSelfRefTag = 1;
@@ -1620,21 +1620,21 @@
1620 char *zCopy = 0;
1621 char **azParent = 0;
1622 Manifest *p = 0;
1623 int i, j;
1624 int n = (int)strlen(zValue);
1625 int mxParent = (n+1)/(HNAME_LEN_MIN+1);
1626
1627 if( mxParent<1 ) return;
1628 zCopy = fossil_strdup(zValue);
1629 azParent = fossil_malloc( sizeof(azParent[0])*mxParent );
1630 for(nParent=0, i=0; zCopy[i]; i++){
1631 char *z = &zCopy[i];
1632 azParent[nParent++] = z;
1633 if( nParent>mxParent ) goto reparent_abort;
1634 for(j=HNAME_LEN_MIN; z[j]>' '; j++){}
1635 if( hname_validate(z, j)==HNAME_NONE ) goto reparent_abort;
1636 if( z[j]==0 ) break;
1637 z[j] = 0;
1638 i += j;
1639 }
1640 if( !db_exists("SELECT 1 FROM plink WHERE cid=%d AND pid=%d",
1641
--- src/manifest.c
+++ src/manifest.c
@@ -449,15 +449,15 @@
449 defossilize(zName);
450 if( !file_is_simple_pathname(zName, 0) ){
451 SYNTAX("invalid filename on A-card");
452 }
453 defossilize(zTarget);
454 if( !hname_validate(zTarget,nTarget)
455 && !wiki_name_is_wellformed((const unsigned char *)zTarget) ){
456 SYNTAX("invalid target on A-card");
457 }
458 if( zSrc && !hname_validate(zSrc,nSrc) ){
459 SYNTAX("invalid source on A-card");
460 }
461 p->zAttachName = (char*)file_tail(zName);
462 p->zAttachSrc = zSrc;
463 p->zAttachTarget = zTarget;
@@ -471,11 +471,11 @@
471 */
472 case 'B': {
473 if( p->zBaseline ) SYNTAX("more than one B-card");
474 p->zBaseline = next_token(&x, &sz);
475 if( p->zBaseline==0 ) SYNTAX("missing hash on B-card");
476 if( !hname_validate(p->zBaseline,sz) ){
477 SYNTAX("invalid hash on B-card");
478 }
479 break;
480 }
481
@@ -522,11 +522,11 @@
522 case 'E': {
523 if( p->rEventDate>0.0 ) SYNTAX("more than one E-card");
524 p->rEventDate = db_double(0.0,"SELECT julianday(%Q)", next_token(&x,0));
525 if( p->rEventDate<=0.0 ) SYNTAX("malformed date on E-card");
526 p->zEventId = next_token(&x, &sz);
527 if( !hname_validate(p->zEventId, sz) ){
528 SYNTAX("malformed hash on E-card");
529 }
530 break;
531 }
532
@@ -545,11 +545,11 @@
545 if( !file_is_simple_pathname(zName, 0) ){
546 SYNTAX("F-card filename is not a simple path");
547 }
548 zUuid = next_token(&x, &sz);
549 if( p->zBaseline==0 || zUuid!=0 ){
550 if( !hname_validate(zUuid,sz) ){
551 SYNTAX("F-card hash invalid");
552 }
553 }
554 zPerm = next_token(&x,0);
555 zPriorName = next_token(&x,0);
@@ -645,11 +645,11 @@
645 ** occur in clusters only.
646 */
647 case 'M': {
648 zUuid = next_token(&x, &sz);
649 if( zUuid==0 ) SYNTAX("missing hash on M-card");
650 if( !hname_validate(zUuid,sz) ){
651 SYNTAX("Invalid hash on M-card");
652 }
653 if( p->nCChild>=p->nCChildAlloc ){
654 p->nCChildAlloc = p->nCChildAlloc*2 + 10;
655 p->azCChild = fossil_realloc(p->azCChild
@@ -685,11 +685,11 @@
685 ** check-in historically has an empty P-card, so empty P-cards
686 ** must be accepted.
687 */
688 case 'P': {
689 while( (zUuid = next_token(&x, &sz))!=0 ){
690 if( !hname_validate(zUuid, sz) ){
691 SYNTAX("invalid hash on P-card");
692 }
693 if( p->nParent>=p->nParentAlloc ){
694 p->nParentAlloc = p->nParentAlloc*2 + 5;
695 p->azParent = fossil_realloc(p->azParent,
@@ -710,20 +710,20 @@
710 case 'Q': {
711 if( (zUuid=next_token(&x, &sz))==0 ) SYNTAX("missing hash on Q-card");
712 if( zUuid[0]!='+' && zUuid[0]!='-' ){
713 SYNTAX("Q-card does not begin with '+' or '-'");
714 }
715 if( !hname_validate(&zUuid[1], sz-1) ){
716 SYNTAX("invalid hash on Q-card");
717 }
718 n = p->nCherrypick;
719 p->nCherrypick++;
720 p->aCherrypick = fossil_realloc(p->aCherrypick,
721 p->nCherrypick*sizeof(p->aCherrypick[0]));
722 p->aCherrypick[n].zCPTarget = zUuid;
723 p->aCherrypick[n].zCPBase = zUuid = next_token(&x, &sz);
724 if( zUuid && !hname_validate(zUuid,sz) ){
725 SYNTAX("invalid second hash on Q-card");
726 }
727 break;
728 }
729
@@ -762,11 +762,11 @@
762 if( zName==0 ) SYNTAX("missing name on T-card");
763 zUuid = next_token(&x, &sz);
764 if( zUuid==0 ) SYNTAX("missing artifact hash on T-card");
765 zValue = next_token(&x, 0);
766 if( zValue ) defossilize(zValue);
767 if( hname_validate(zUuid, sz) ){
768 /* A valid artifact hash */
769 if( p->zEventId ) SYNTAX("non-self-referential T-card in event");
770 }else if( sz==1 && zUuid[0]=='*' ){
771 zUuid = 0;
772 hasSelfRefTag = 1;
@@ -1620,21 +1620,21 @@
1620 char *zCopy = 0;
1621 char **azParent = 0;
1622 Manifest *p = 0;
1623 int i, j;
1624 int n = (int)strlen(zValue);
1625 int mxParent = (n+1)/(HNAME_MIN+1);
1626
1627 if( mxParent<1 ) return;
1628 zCopy = fossil_strdup(zValue);
1629 azParent = fossil_malloc( sizeof(azParent[0])*mxParent );
1630 for(nParent=0, i=0; zCopy[i]; i++){
1631 char *z = &zCopy[i];
1632 azParent[nParent++] = z;
1633 if( nParent>mxParent ) goto reparent_abort;
1634 for(j=HNAME_MIN; z[j]>' '; j++){}
1635 if( !hname_validate(z, j) ) goto reparent_abort;
1636 if( z[j]==0 ) break;
1637 z[j] = 0;
1638 i += j;
1639 }
1640 if( !db_exists("SELECT 1 FROM plink WHERE cid=%d AND pid=%d",
1641
+10 -10
--- src/name.c
+++ src/name.c
@@ -229,13 +229,13 @@
229229
);
230230
return rid;
231231
}
232232
233233
/* artifact hash or prefix */
234
- if( nTag>=4 && nTag<=HNAME_LEN_MAX && validate16(zTag, nTag) ){
234
+ if( nTag>=4 && nTag<=HNAME_MAX && validate16(zTag, nTag) ){
235235
Stmt q;
236
- char zUuid[HNAME_LEN_MAX+1];
236
+ char zUuid[HNAME_MAX+1];
237237
memcpy(zUuid, zTag, nTag+1);
238238
canonical16(zUuid, nTag);
239239
rid = 0;
240240
if( zType[0]=='*' ){
241241
db_prepare(&q, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUuid);
@@ -350,11 +350,11 @@
350350
*/
351351
int name_collisions(const char *zName){
352352
int c = 0; /* count of collisions for zName */
353353
int nLen; /* length of zName */
354354
nLen = strlen(zName);
355
- if( nLen>=4 && nLen<=HNAME_LEN_MAX && validate16(zName, nLen) ){
355
+ if( nLen>=4 && nLen<=HNAME_MAX && validate16(zName, nLen) ){
356356
c = db_int(0,
357357
"SELECT"
358358
" (SELECT count(*) FROM ticket"
359359
" WHERE tkt_uuid GLOB '%q*') +"
360360
" (SELECT count(*) FROM tag"
@@ -664,11 +664,11 @@
664664
/*
665665
** COMMAND: whatis*
666666
**
667667
** Usage: %fossil whatis NAME
668668
**
669
-** Resolve the symbol NAME into its canonical 40-character SHA1-hash
669
+** Resolve the symbol NAME into its canonical artifact hash
670670
** artifact name and provide a description of what role that artifact
671671
** plays.
672672
**
673673
** Options:
674674
**
@@ -1150,26 +1150,26 @@
11501150
*/
11511151
static void collision_report(const char *zSql){
11521152
int i, j, kk;
11531153
int nHash = 0;
11541154
Stmt q;
1155
- char zPrev[HNAME_LEN_MAX+1];
1155
+ char zPrev[HNAME_MAX+1];
11561156
struct {
11571157
int cnt;
11581158
char *azHit[MAX_COLLIDE];
1159
- char z[HNAME_LEN_MAX+1];
1160
- } aCollide[HNAME_LEN_MAX+1];
1159
+ char z[HNAME_MAX+1];
1160
+ } aCollide[HNAME_MAX+1];
11611161
memset(aCollide, 0, sizeof(aCollide));
11621162
memset(zPrev, 0, sizeof(zPrev));
11631163
db_prepare(&q,"%s",zSql/*safe-for-%s*/);
11641164
while( db_step(&q)==SQLITE_ROW ){
11651165
const char *zUuid = db_column_text(&q,0);
11661166
int n = db_column_bytes(&q,0);
11671167
int i;
11681168
nHash++;
11691169
for(i=0; zPrev[i] && zPrev[i]==zUuid[i]; i++){}
1170
- if( i>0 && i<=HNAME_LEN_MAX ){
1170
+ if( i>0 && i<=HNAME_MAX ){
11711171
if( i>=4 && aCollide[i].cnt<MAX_COLLIDE ){
11721172
aCollide[i].azHit[aCollide[i].cnt] = mprintf("%.*s", i, zPrev);
11731173
}
11741174
aCollide[i].cnt++;
11751175
if( aCollide[i].z[0]==0 ) memcpy(aCollide[i].z, zPrev, n+1);
@@ -1178,18 +1178,18 @@
11781178
}
11791179
db_finalize(&q);
11801180
@ <table border=1><thead>
11811181
@ <tr><th>Length<th>Instances<th>First Instance</tr>
11821182
@ </thead><tbody>
1183
- for(i=1; i<=HNAME_LEN_MAX; i++){
1183
+ for(i=1; i<=HNAME_MAX; i++){
11841184
if( aCollide[i].cnt==0 ) continue;
11851185
@ <tr><td>%d(i)<td>%d(aCollide[i].cnt)<td>%h(aCollide[i].z)</tr>
11861186
}
11871187
@ </tbody></table>
11881188
@ <p>Total number of hashes: %d(nHash)</p>
11891189
kk = 0;
1190
- for(i=HNAME_LEN_MAX; i>=4; i--){
1190
+ for(i=HNAME_MAX; i>=4; i--){
11911191
if( aCollide[i].cnt==0 ) continue;
11921192
if( aCollide[i].cnt>200 ) break;
11931193
kk += aCollide[i].cnt;
11941194
if( aCollide[i].cnt<25 ){
11951195
@ <p>Collisions of length %d(i):
11961196
--- src/name.c
+++ src/name.c
@@ -229,13 +229,13 @@
229 );
230 return rid;
231 }
232
233 /* artifact hash or prefix */
234 if( nTag>=4 && nTag<=HNAME_LEN_MAX && validate16(zTag, nTag) ){
235 Stmt q;
236 char zUuid[HNAME_LEN_MAX+1];
237 memcpy(zUuid, zTag, nTag+1);
238 canonical16(zUuid, nTag);
239 rid = 0;
240 if( zType[0]=='*' ){
241 db_prepare(&q, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUuid);
@@ -350,11 +350,11 @@
350 */
351 int name_collisions(const char *zName){
352 int c = 0; /* count of collisions for zName */
353 int nLen; /* length of zName */
354 nLen = strlen(zName);
355 if( nLen>=4 && nLen<=HNAME_LEN_MAX && validate16(zName, nLen) ){
356 c = db_int(0,
357 "SELECT"
358 " (SELECT count(*) FROM ticket"
359 " WHERE tkt_uuid GLOB '%q*') +"
360 " (SELECT count(*) FROM tag"
@@ -664,11 +664,11 @@
664 /*
665 ** COMMAND: whatis*
666 **
667 ** Usage: %fossil whatis NAME
668 **
669 ** Resolve the symbol NAME into its canonical 40-character SHA1-hash
670 ** artifact name and provide a description of what role that artifact
671 ** plays.
672 **
673 ** Options:
674 **
@@ -1150,26 +1150,26 @@
1150 */
1151 static void collision_report(const char *zSql){
1152 int i, j, kk;
1153 int nHash = 0;
1154 Stmt q;
1155 char zPrev[HNAME_LEN_MAX+1];
1156 struct {
1157 int cnt;
1158 char *azHit[MAX_COLLIDE];
1159 char z[HNAME_LEN_MAX+1];
1160 } aCollide[HNAME_LEN_MAX+1];
1161 memset(aCollide, 0, sizeof(aCollide));
1162 memset(zPrev, 0, sizeof(zPrev));
1163 db_prepare(&q,"%s",zSql/*safe-for-%s*/);
1164 while( db_step(&q)==SQLITE_ROW ){
1165 const char *zUuid = db_column_text(&q,0);
1166 int n = db_column_bytes(&q,0);
1167 int i;
1168 nHash++;
1169 for(i=0; zPrev[i] && zPrev[i]==zUuid[i]; i++){}
1170 if( i>0 && i<=HNAME_LEN_MAX ){
1171 if( i>=4 && aCollide[i].cnt<MAX_COLLIDE ){
1172 aCollide[i].azHit[aCollide[i].cnt] = mprintf("%.*s", i, zPrev);
1173 }
1174 aCollide[i].cnt++;
1175 if( aCollide[i].z[0]==0 ) memcpy(aCollide[i].z, zPrev, n+1);
@@ -1178,18 +1178,18 @@
1178 }
1179 db_finalize(&q);
1180 @ <table border=1><thead>
1181 @ <tr><th>Length<th>Instances<th>First Instance</tr>
1182 @ </thead><tbody>
1183 for(i=1; i<=HNAME_LEN_MAX; i++){
1184 if( aCollide[i].cnt==0 ) continue;
1185 @ <tr><td>%d(i)<td>%d(aCollide[i].cnt)<td>%h(aCollide[i].z)</tr>
1186 }
1187 @ </tbody></table>
1188 @ <p>Total number of hashes: %d(nHash)</p>
1189 kk = 0;
1190 for(i=HNAME_LEN_MAX; i>=4; i--){
1191 if( aCollide[i].cnt==0 ) continue;
1192 if( aCollide[i].cnt>200 ) break;
1193 kk += aCollide[i].cnt;
1194 if( aCollide[i].cnt<25 ){
1195 @ <p>Collisions of length %d(i):
1196
--- src/name.c
+++ src/name.c
@@ -229,13 +229,13 @@
229 );
230 return rid;
231 }
232
233 /* artifact hash or prefix */
234 if( nTag>=4 && nTag<=HNAME_MAX && validate16(zTag, nTag) ){
235 Stmt q;
236 char zUuid[HNAME_MAX+1];
237 memcpy(zUuid, zTag, nTag+1);
238 canonical16(zUuid, nTag);
239 rid = 0;
240 if( zType[0]=='*' ){
241 db_prepare(&q, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUuid);
@@ -350,11 +350,11 @@
350 */
351 int name_collisions(const char *zName){
352 int c = 0; /* count of collisions for zName */
353 int nLen; /* length of zName */
354 nLen = strlen(zName);
355 if( nLen>=4 && nLen<=HNAME_MAX && validate16(zName, nLen) ){
356 c = db_int(0,
357 "SELECT"
358 " (SELECT count(*) FROM ticket"
359 " WHERE tkt_uuid GLOB '%q*') +"
360 " (SELECT count(*) FROM tag"
@@ -664,11 +664,11 @@
664 /*
665 ** COMMAND: whatis*
666 **
667 ** Usage: %fossil whatis NAME
668 **
669 ** Resolve the symbol NAME into its canonical artifact hash
670 ** artifact name and provide a description of what role that artifact
671 ** plays.
672 **
673 ** Options:
674 **
@@ -1150,26 +1150,26 @@
1150 */
1151 static void collision_report(const char *zSql){
1152 int i, j, kk;
1153 int nHash = 0;
1154 Stmt q;
1155 char zPrev[HNAME_MAX+1];
1156 struct {
1157 int cnt;
1158 char *azHit[MAX_COLLIDE];
1159 char z[HNAME_MAX+1];
1160 } aCollide[HNAME_MAX+1];
1161 memset(aCollide, 0, sizeof(aCollide));
1162 memset(zPrev, 0, sizeof(zPrev));
1163 db_prepare(&q,"%s",zSql/*safe-for-%s*/);
1164 while( db_step(&q)==SQLITE_ROW ){
1165 const char *zUuid = db_column_text(&q,0);
1166 int n = db_column_bytes(&q,0);
1167 int i;
1168 nHash++;
1169 for(i=0; zPrev[i] && zPrev[i]==zUuid[i]; i++){}
1170 if( i>0 && i<=HNAME_MAX ){
1171 if( i>=4 && aCollide[i].cnt<MAX_COLLIDE ){
1172 aCollide[i].azHit[aCollide[i].cnt] = mprintf("%.*s", i, zPrev);
1173 }
1174 aCollide[i].cnt++;
1175 if( aCollide[i].z[0]==0 ) memcpy(aCollide[i].z, zPrev, n+1);
@@ -1178,18 +1178,18 @@
1178 }
1179 db_finalize(&q);
1180 @ <table border=1><thead>
1181 @ <tr><th>Length<th>Instances<th>First Instance</tr>
1182 @ </thead><tbody>
1183 for(i=1; i<=HNAME_MAX; i++){
1184 if( aCollide[i].cnt==0 ) continue;
1185 @ <tr><td>%d(i)<td>%d(aCollide[i].cnt)<td>%h(aCollide[i].z)</tr>
1186 }
1187 @ </tbody></table>
1188 @ <p>Total number of hashes: %d(nHash)</p>
1189 kk = 0;
1190 for(i=HNAME_MAX; i>=4; i--){
1191 if( aCollide[i].cnt==0 ) continue;
1192 if( aCollide[i].cnt>200 ) break;
1193 kk += aCollide[i].cnt;
1194 if( aCollide[i].cnt<25 ){
1195 @ <p>Collisions of length %d(i):
1196
+1 -1
--- src/rebuild.c
+++ src/rebuild.c
@@ -1029,11 +1029,11 @@
10291029
**
10301030
**
10311031
** This command exports all artifacts of a given repository and
10321032
** writes all artifacts to the file system. The DESTINATION directory
10331033
** will be populated with subdirectories AA and files AA/BBBBBBBBB.., where
1034
-** AABBBBBBBBB.. is the 40 character artifact ID, AA the first 2 characters.
1034
+** AABBBBBBBBB.. is the 40+ character artifact ID, AA the first 2 characters.
10351035
** If -L|--prefixlength is given, the length (default 2) of the directory
10361036
** prefix can be set to 0,1,..,9 characters.
10371037
**
10381038
** Options:
10391039
** -R|--repository REPOSITORY deconstruct given REPOSITORY
10401040
--- src/rebuild.c
+++ src/rebuild.c
@@ -1029,11 +1029,11 @@
1029 **
1030 **
1031 ** This command exports all artifacts of a given repository and
1032 ** writes all artifacts to the file system. The DESTINATION directory
1033 ** will be populated with subdirectories AA and files AA/BBBBBBBBB.., where
1034 ** AABBBBBBBBB.. is the 40 character artifact ID, AA the first 2 characters.
1035 ** If -L|--prefixlength is given, the length (default 2) of the directory
1036 ** prefix can be set to 0,1,..,9 characters.
1037 **
1038 ** Options:
1039 ** -R|--repository REPOSITORY deconstruct given REPOSITORY
1040
--- src/rebuild.c
+++ src/rebuild.c
@@ -1029,11 +1029,11 @@
1029 **
1030 **
1031 ** This command exports all artifacts of a given repository and
1032 ** writes all artifacts to the file system. The DESTINATION directory
1033 ** will be populated with subdirectories AA and files AA/BBBBBBBBB.., where
1034 ** AABBBBBBBBB.. is the 40+ character artifact ID, AA the first 2 characters.
1035 ** If -L|--prefixlength is given, the length (default 2) of the directory
1036 ** prefix can be set to 0,1,..,9 characters.
1037 **
1038 ** Options:
1039 ** -R|--repository REPOSITORY deconstruct given REPOSITORY
1040
+5 -5
--- src/shun.c
+++ src/shun.c
@@ -84,11 +84,11 @@
8484
}
8585
zCanonical[j+1] = zCanonical[j] = 0;
8686
p = zCanonical;
8787
while( *p ){
8888
int nUuid = strlen(p);
89
- if( hname_validate(p, nUuid)==HNAME_NONE ){
89
+ if( !hname_validate(p, nUuid) ){
9090
@ <p class="generalError">Error: Bad artifact IDs.</p>
9191
fossil_free(zCanonical);
9292
zCanonical = 0;
9393
break;
9494
}else{
@@ -167,18 +167,18 @@
167167
@ artifact content will be purged from the repository the next time the
168168
@ repository is rebuilt. A list of shunned artifacts can be seen at the
169169
@ bottom of this page.</p>
170170
@
171171
@ <a name="addshun"></a>
172
- @ <p>To shun artifacts, enter their artifact IDs (the 40-character SHA1
173
- @ hash of the artifacts) in the
172
+ @ <p>To shun artifacts, enter their artifact hashes (the 40- or
173
+ @ 64-character lowercase hexadecimal hash of the artifact content) in the
174174
@ following box and press the "Shun" button. This will cause the artifacts
175175
@ to be removed from the repository and will prevent the artifacts from being
176176
@ readded to the repository by subsequent sync operation.</p>
177177
@
178
- @ <p>Note that you must enter the full 40-character artifact IDs, not
179
- @ an abbreviation or a symbolic tag.</p>
178
+ @ <p>Note that you must enter the full 40- or 64-character artifact hashes,
179
+ @ not an abbreviation or a symbolic tag.</p>
180180
@
181181
@ <p>Warning: Shunning should only be used to remove inappropriate content
182182
@ from the repository. Inappropriate content includes such things as
183183
@ spam added to Wiki, files that violate copyright or patent agreements,
184184
@ or artifacts that by design or accident interfere with the processing
185185
--- src/shun.c
+++ src/shun.c
@@ -84,11 +84,11 @@
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{
@@ -167,18 +167,18 @@
167 @ artifact content will be purged from the repository the next time the
168 @ repository is rebuilt. A list of shunned artifacts can be seen at the
169 @ bottom of this page.</p>
170 @
171 @ <a name="addshun"></a>
172 @ <p>To shun artifacts, enter their artifact IDs (the 40-character SHA1
173 @ hash of the artifacts) in the
174 @ following box and press the "Shun" button. This will cause the artifacts
175 @ to be removed from the repository and will prevent the artifacts from being
176 @ readded to the repository by subsequent sync operation.</p>
177 @
178 @ <p>Note that you must enter the full 40-character artifact IDs, not
179 @ an abbreviation or a symbolic tag.</p>
180 @
181 @ <p>Warning: Shunning should only be used to remove inappropriate content
182 @ from the repository. Inappropriate content includes such things as
183 @ spam added to Wiki, files that violate copyright or patent agreements,
184 @ or artifacts that by design or accident interfere with the processing
185
--- src/shun.c
+++ src/shun.c
@@ -84,11 +84,11 @@
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) ){
90 @ <p class="generalError">Error: Bad artifact IDs.</p>
91 fossil_free(zCanonical);
92 zCanonical = 0;
93 break;
94 }else{
@@ -167,18 +167,18 @@
167 @ artifact content will be purged from the repository the next time the
168 @ repository is rebuilt. A list of shunned artifacts can be seen at the
169 @ bottom of this page.</p>
170 @
171 @ <a name="addshun"></a>
172 @ <p>To shun artifacts, enter their artifact hashes (the 40- or
173 @ 64-character lowercase hexadecimal hash of the artifact content) in the
174 @ following box and press the "Shun" button. This will cause the artifacts
175 @ to be removed from the repository and will prevent the artifacts from being
176 @ readded to the repository by subsequent sync operation.</p>
177 @
178 @ <p>Note that you must enter the full 40- or 64-character artifact hashes,
179 @ not an abbreviation or a symbolic tag.</p>
180 @
181 @ <p>Warning: Shunning should only be used to remove inappropriate content
182 @ from the repository. Inappropriate content includes such things as
183 @ spam added to Wiki, files that violate copyright or patent agreements,
184 @ or artifacts that by design or accident interfere with the processing
185
+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( hname_validate(blob_buffer(&uuid), blob_size(&uuid))!=HNAME_NONE ){
45
+ if( !hname_validate(blob_buffer(&uuid), blob_size(&uuid)) ){
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( 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
--- 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)) ){
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
+5 -5
--- src/vfile.c
+++ src/vfile.c
@@ -21,12 +21,12 @@
2121
#include "vfile.h"
2222
#include <assert.h>
2323
#include <sys/types.h>
2424
2525
/*
26
-** The input is guaranteed to be a 40-character well-formed UUID.
27
-** Find its rid.
26
+** The input is guaranteed to be a 40- or 64-character well-formed
27
+** artifact hash. Find its rid.
2828
*/
2929
int fast_uuid_to_rid(const char *zUuid){
3030
static Stmt q;
3131
int rid;
3232
db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid");
@@ -51,15 +51,15 @@
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[HNAME_LEN_MAX+1];
56
+ char z[HNAME_MAX+1];
5757
5858
sz = strlen(zUuid);
59
- if( hname_validate(zUuid, sz)!=HNAME_NONE ){
60
- return 0;
59
+ if( !hname_validate(zUuid, sz) ){
60
+ return 0; /* Not a valid hash */
6161
}
6262
memcpy(z, zUuid, sz+1);
6363
canonical16(z, sz);
6464
rid = fast_uuid_to_rid(z);
6565
if( rid==0 && phantomize ){
6666
--- src/vfile.c
+++ src/vfile.c
@@ -21,12 +21,12 @@
21 #include "vfile.h"
22 #include <assert.h>
23 #include <sys/types.h>
24
25 /*
26 ** The input is guaranteed to be a 40-character well-formed UUID.
27 ** Find its rid.
28 */
29 int fast_uuid_to_rid(const char *zUuid){
30 static Stmt q;
31 int rid;
32 db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid");
@@ -51,15 +51,15 @@
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
--- src/vfile.c
+++ src/vfile.c
@@ -21,12 +21,12 @@
21 #include "vfile.h"
22 #include <assert.h>
23 #include <sys/types.h>
24
25 /*
26 ** The input is guaranteed to be a 40- or 64-character well-formed
27 ** artifact hash. Find its rid.
28 */
29 int fast_uuid_to_rid(const char *zUuid){
30 static Stmt q;
31 int rid;
32 db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid");
@@ -51,15 +51,15 @@
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_MAX+1];
57
58 sz = strlen(zUuid);
59 if( !hname_validate(zUuid, sz) ){
60 return 0; /* Not a valid hash */
61 }
62 memcpy(z, zUuid, sz+1);
63 canonical16(z, sz);
64 rid = fast_uuid_to_rid(z);
65 if( rid==0 && phantomize ){
66
+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 && hname_validate(zETime, nETime)!=HNAME_NONE ){
1128
- char zUuid[HNAME_LEN_MAX+1];
1127
+ if( nETime>=4 && hname_validate(zETime, nETime) ){
1128
+ char zUuid[HNAME_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 && 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/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) ){
1128 char zUuid[HNAME_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>HNAME_LEN_MAX ) return 0;
1072
+ if( n<4 || n>HNAME_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>HNAME_LEN_MAX ) 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_MAX ) return 0;
1073 if( !validate16(z, n) ) return 0;
1074 return 1;
1075 }
1076
1077 /*
1078

Keyboard Shortcuts

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