Fossil SCM
Refactoring and cleanup of some of the hash name interfaces.
Commit
1c8768b0deed45e9afc9de3e42a8ce1d220a03ff
Parent
94f4c0aab5678f8…
14 files changed
+6
-1
+1
-1
+4
-3
+2
-2
+1
-1
+12
-13
+13
-13
+10
-10
+1
-1
+5
-5
+1
-1
+5
-5
+2
-2
+1
-1
+6
-1
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -648,13 +648,18 @@ | ||
| 648 | 648 | pFrom->iCursor = i; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | /* |
| 652 | 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. | |
| 653 | 658 | */ |
| 654 | 659 | 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)); | |
| 656 | 661 | } |
| 657 | 662 | |
| 658 | 663 | /* |
| 659 | 664 | ** Return true if the blob contains a valid filename |
| 660 | 665 | */ |
| 661 | 666 |
| --- 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 @@ | ||
| 368 | 368 | FileTreeNode *pNew; |
| 369 | 369 | int iStart = i; |
| 370 | 370 | int nByte; |
| 371 | 371 | while( zPath[i] && zPath[i]!='/' ){ i++; } |
| 372 | 372 | 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; | |
| 374 | 374 | pNew = fossil_malloc( nByte ); |
| 375 | 375 | memset(pNew, 0, sizeof(*pNew)); |
| 376 | 376 | pNew->zFullName = (char*)&pNew[1]; |
| 377 | 377 | memcpy(pNew->zFullName, zPath, i); |
| 378 | 378 | pNew->zFullName[i] = 0; |
| 379 | 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_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 @@ | ||
| 447 | 447 | db_column_blob(&q, 0, &h1); |
| 448 | 448 | blob_zero(&c1); |
| 449 | 449 | db_column_blob(&q, 1, &c1); |
| 450 | 450 | blob_uncompress(&c1, &c1); |
| 451 | 451 | 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 ){ | |
| 453 | 453 | Blob basis; |
| 454 | 454 | rid = db_int(0,"SELECT rid FROM blob WHERE uuid=%Q", |
| 455 | 455 | db_column_text(&q,2)); |
| 456 | 456 | content_get(rid, &basis); |
| 457 | 457 | blob_delta_apply(&basis, &c1, &c2); |
| @@ -597,12 +597,13 @@ | ||
| 597 | 597 | ** repo, then the delta encodings cannot be decoded and the bundle cannot |
| 598 | 598 | ** be extracted. */ |
| 599 | 599 | zMissingDeltas = db_text(0, |
| 600 | 600 | "SELECT group_concat(substr(delta,1,10),' ')" |
| 601 | 601 | " 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); | |
| 604 | 605 | if( zMissingDeltas && zMissingDeltas[0] ){ |
| 605 | 606 | fossil_fatal("delta basis artifacts not found in repository: %s", |
| 606 | 607 | zMissingDeltas); |
| 607 | 608 | } |
| 608 | 609 | |
| 609 | 610 |
| --- 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 |
M
src/db.c
+2
-2
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -2080,13 +2080,13 @@ | ||
| 2080 | 2080 | ** email address will contain a "@" character and "@" is not valid within |
| 2081 | 2081 | ** an SHA1 hash so there is no chance that a valid email address will go |
| 2082 | 2082 | ** unconcealed. |
| 2083 | 2083 | */ |
| 2084 | 2084 | char *db_conceal(const char *zContent, int n){ |
| 2085 | - static char zHash[HNAME_LEN_MAX+1]; | |
| 2085 | + static char zHash[HNAME_MAX+1]; | |
| 2086 | 2086 | Blob out; |
| 2087 | - if( hname_validate(zContent, n)!=HNAME_NONE ){ | |
| 2087 | + if( hname_validate(zContent, n) ){ | |
| 2088 | 2088 | memcpy(zHash, zContent, n); |
| 2089 | 2089 | zHash[n] = 0; |
| 2090 | 2090 | }else{ |
| 2091 | 2091 | sha1sum_step_text(zContent, n); |
| 2092 | 2092 | sha1sum_finish(&out); |
| 2093 | 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_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 @@ | ||
| 384 | 384 | rid = db_int(0, |
| 385 | 385 | "SELECT rid FROM tagxref" |
| 386 | 386 | " WHERE tagid=(SELECT tagid FROM tag WHERE tagname GLOB '%q*')" |
| 387 | 387 | " ORDER BY mtime DESC", zTag |
| 388 | 388 | ); |
| 389 | - if( rid && strlen(zId)<40 ){ | |
| 389 | + if( rid && strlen(zId)<HNAME_MIN ){ | |
| 390 | 390 | zId = db_text(0, |
| 391 | 391 | "SELECT substr(tagname,7) FROM tag WHERE tagname GLOB '%q*'", |
| 392 | 392 | zTag |
| 393 | 393 | ); |
| 394 | 394 | } |
| 395 | 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)<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 @@ | ||
| 26 | 26 | |
| 27 | 27 | #if INTERFACE |
| 28 | 28 | /* |
| 29 | 29 | ** Code numbers for the allowed hash algorithms. |
| 30 | 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 */ | |
| 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 | 35 | |
| 36 | 36 | /* |
| 37 | 37 | ** Minimum and maximum lengths for a hash value when hex encoded. |
| 38 | 38 | */ |
| 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 */ | |
| 41 | 41 | |
| 42 | 42 | /* |
| 43 | 43 | ** Hash lengths for the various algorithms |
| 44 | 44 | */ |
| 45 | 45 | #define HNAME_LEN_SHA1 40 |
| @@ -52,36 +52,35 @@ | ||
| 52 | 52 | /* |
| 53 | 53 | ** Convert a hash algorithm code number into a string name for that algorithm. |
| 54 | 54 | */ |
| 55 | 55 | const char *hname_algname(int aid){ |
| 56 | 56 | if( aid==HNAME_K224 ) return "SHA3-224"; |
| 57 | - if( aid==HNAME_K256 ) return "SHA3-256"; | |
| 58 | 57 | return "SHA1"; |
| 59 | 58 | } |
| 60 | 59 | |
| 61 | 60 | /* |
| 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. | |
| 64 | 63 | */ |
| 65 | 64 | int hname_algid(const char *zName){ |
| 66 | 65 | if( fossil_stricmp(zName,"sha1")==0 ) return HNAME_SHA1; |
| 67 | 66 | if( fossil_stricmp(zName,"sha3-224")==0 ) return HNAME_K224; |
| 68 | 67 | if( fossil_stricmp(zName,"sha3-256")==0 ) return HNAME_K256; |
| 69 | - return -1; | |
| 68 | + return HNAME_ERROR; | |
| 70 | 69 | } |
| 71 | 70 | |
| 72 | 71 | /* |
| 73 | 72 | ** 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 | |
| 75 | 74 | ** is not a valid artifact hash string. |
| 76 | 75 | */ |
| 77 | 76 | int hname_validate(const char *zHash, int nHash){ |
| 78 | 77 | int id; |
| 79 | 78 | switch( nHash ){ |
| 80 | 79 | case HNAME_LEN_SHA1: id = HNAME_SHA1; break; |
| 81 | 80 | case HNAME_LEN_K224: id = HNAME_K224; break; |
| 82 | 81 | case HNAME_LEN_K256: id = HNAME_K256; break; |
| 83 | - default: return HNAME_NONE; | |
| 82 | + default: return HNAME_ERROR; | |
| 84 | 83 | } |
| 85 | - if( !validate16(zHash, nHash) ) return HNAME_NONE; | |
| 84 | + if( !validate16(zHash, nHash) ) return HNAME_ERROR; | |
| 86 | 85 | return id; |
| 87 | 86 | } |
| 88 | 87 |
| --- 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 @@ | ||
| 449 | 449 | defossilize(zName); |
| 450 | 450 | if( !file_is_simple_pathname(zName, 0) ){ |
| 451 | 451 | SYNTAX("invalid filename on A-card"); |
| 452 | 452 | } |
| 453 | 453 | defossilize(zTarget); |
| 454 | - if( hname_validate(zTarget,nTarget)==HNAME_NONE | |
| 454 | + if( !hname_validate(zTarget,nTarget) | |
| 455 | 455 | && !wiki_name_is_wellformed((const unsigned char *)zTarget) ){ |
| 456 | 456 | SYNTAX("invalid target on A-card"); |
| 457 | 457 | } |
| 458 | - if( zSrc && hname_validate(zSrc,nSrc)==HNAME_NONE ){ | |
| 458 | + if( zSrc && !hname_validate(zSrc,nSrc) ){ | |
| 459 | 459 | SYNTAX("invalid source on A-card"); |
| 460 | 460 | } |
| 461 | 461 | p->zAttachName = (char*)file_tail(zName); |
| 462 | 462 | p->zAttachSrc = zSrc; |
| 463 | 463 | p->zAttachTarget = zTarget; |
| @@ -471,11 +471,11 @@ | ||
| 471 | 471 | */ |
| 472 | 472 | case 'B': { |
| 473 | 473 | if( p->zBaseline ) SYNTAX("more than one B-card"); |
| 474 | 474 | p->zBaseline = next_token(&x, &sz); |
| 475 | 475 | 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) ){ | |
| 477 | 477 | SYNTAX("invalid hash on B-card"); |
| 478 | 478 | } |
| 479 | 479 | break; |
| 480 | 480 | } |
| 481 | 481 | |
| @@ -522,11 +522,11 @@ | ||
| 522 | 522 | case 'E': { |
| 523 | 523 | if( p->rEventDate>0.0 ) SYNTAX("more than one E-card"); |
| 524 | 524 | p->rEventDate = db_double(0.0,"SELECT julianday(%Q)", next_token(&x,0)); |
| 525 | 525 | if( p->rEventDate<=0.0 ) SYNTAX("malformed date on E-card"); |
| 526 | 526 | p->zEventId = next_token(&x, &sz); |
| 527 | - if( hname_validate(p->zEventId, sz)==HNAME_NONE ){ | |
| 527 | + if( !hname_validate(p->zEventId, sz) ){ | |
| 528 | 528 | SYNTAX("malformed hash on E-card"); |
| 529 | 529 | } |
| 530 | 530 | break; |
| 531 | 531 | } |
| 532 | 532 | |
| @@ -545,11 +545,11 @@ | ||
| 545 | 545 | if( !file_is_simple_pathname(zName, 0) ){ |
| 546 | 546 | SYNTAX("F-card filename is not a simple path"); |
| 547 | 547 | } |
| 548 | 548 | zUuid = next_token(&x, &sz); |
| 549 | 549 | if( p->zBaseline==0 || zUuid!=0 ){ |
| 550 | - if( hname_validate(zUuid,sz)==HNAME_NONE ){ | |
| 550 | + if( !hname_validate(zUuid,sz) ){ | |
| 551 | 551 | SYNTAX("F-card hash invalid"); |
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | zPerm = next_token(&x,0); |
| 555 | 555 | zPriorName = next_token(&x,0); |
| @@ -645,11 +645,11 @@ | ||
| 645 | 645 | ** occur in clusters only. |
| 646 | 646 | */ |
| 647 | 647 | case 'M': { |
| 648 | 648 | zUuid = next_token(&x, &sz); |
| 649 | 649 | if( zUuid==0 ) SYNTAX("missing hash on M-card"); |
| 650 | - if( hname_validate(zUuid,sz)==HNAME_NONE ){ | |
| 650 | + if( !hname_validate(zUuid,sz) ){ | |
| 651 | 651 | SYNTAX("Invalid hash on M-card"); |
| 652 | 652 | } |
| 653 | 653 | if( p->nCChild>=p->nCChildAlloc ){ |
| 654 | 654 | p->nCChildAlloc = p->nCChildAlloc*2 + 10; |
| 655 | 655 | p->azCChild = fossil_realloc(p->azCChild |
| @@ -685,11 +685,11 @@ | ||
| 685 | 685 | ** check-in historically has an empty P-card, so empty P-cards |
| 686 | 686 | ** must be accepted. |
| 687 | 687 | */ |
| 688 | 688 | case 'P': { |
| 689 | 689 | while( (zUuid = next_token(&x, &sz))!=0 ){ |
| 690 | - if( hname_validate(zUuid, sz)==HNAME_NONE ){ | |
| 690 | + if( !hname_validate(zUuid, sz) ){ | |
| 691 | 691 | SYNTAX("invalid hash on P-card"); |
| 692 | 692 | } |
| 693 | 693 | if( p->nParent>=p->nParentAlloc ){ |
| 694 | 694 | p->nParentAlloc = p->nParentAlloc*2 + 5; |
| 695 | 695 | p->azParent = fossil_realloc(p->azParent, |
| @@ -710,20 +710,20 @@ | ||
| 710 | 710 | case 'Q': { |
| 711 | 711 | if( (zUuid=next_token(&x, &sz))==0 ) SYNTAX("missing hash on Q-card"); |
| 712 | 712 | if( zUuid[0]!='+' && zUuid[0]!='-' ){ |
| 713 | 713 | SYNTAX("Q-card does not begin with '+' or '-'"); |
| 714 | 714 | } |
| 715 | - if( hname_validate(&zUuid[1], sz-1)==HNAME_NONE ){ | |
| 715 | + if( !hname_validate(&zUuid[1], sz-1) ){ | |
| 716 | 716 | SYNTAX("invalid hash on Q-card"); |
| 717 | 717 | } |
| 718 | 718 | n = p->nCherrypick; |
| 719 | 719 | p->nCherrypick++; |
| 720 | 720 | p->aCherrypick = fossil_realloc(p->aCherrypick, |
| 721 | 721 | p->nCherrypick*sizeof(p->aCherrypick[0])); |
| 722 | 722 | p->aCherrypick[n].zCPTarget = zUuid; |
| 723 | 723 | 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) ){ | |
| 725 | 725 | SYNTAX("invalid second hash on Q-card"); |
| 726 | 726 | } |
| 727 | 727 | break; |
| 728 | 728 | } |
| 729 | 729 | |
| @@ -762,11 +762,11 @@ | ||
| 762 | 762 | if( zName==0 ) SYNTAX("missing name on T-card"); |
| 763 | 763 | zUuid = next_token(&x, &sz); |
| 764 | 764 | if( zUuid==0 ) SYNTAX("missing artifact hash on T-card"); |
| 765 | 765 | zValue = next_token(&x, 0); |
| 766 | 766 | if( zValue ) defossilize(zValue); |
| 767 | - if( hname_validate(zUuid, sz)!=HNAME_NONE ){ | |
| 767 | + if( hname_validate(zUuid, sz) ){ | |
| 768 | 768 | /* A valid artifact hash */ |
| 769 | 769 | if( p->zEventId ) SYNTAX("non-self-referential T-card in event"); |
| 770 | 770 | }else if( sz==1 && zUuid[0]=='*' ){ |
| 771 | 771 | zUuid = 0; |
| 772 | 772 | hasSelfRefTag = 1; |
| @@ -1620,21 +1620,21 @@ | ||
| 1620 | 1620 | char *zCopy = 0; |
| 1621 | 1621 | char **azParent = 0; |
| 1622 | 1622 | Manifest *p = 0; |
| 1623 | 1623 | int i, j; |
| 1624 | 1624 | int n = (int)strlen(zValue); |
| 1625 | - int mxParent = (n+1)/(HNAME_LEN_MIN+1); | |
| 1625 | + int mxParent = (n+1)/(HNAME_MIN+1); | |
| 1626 | 1626 | |
| 1627 | 1627 | if( mxParent<1 ) return; |
| 1628 | 1628 | zCopy = fossil_strdup(zValue); |
| 1629 | 1629 | azParent = fossil_malloc( sizeof(azParent[0])*mxParent ); |
| 1630 | 1630 | for(nParent=0, i=0; zCopy[i]; i++){ |
| 1631 | 1631 | char *z = &zCopy[i]; |
| 1632 | 1632 | azParent[nParent++] = z; |
| 1633 | 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; | |
| 1634 | + for(j=HNAME_MIN; z[j]>' '; j++){} | |
| 1635 | + if( !hname_validate(z, j) ) goto reparent_abort; | |
| 1636 | 1636 | if( z[j]==0 ) break; |
| 1637 | 1637 | z[j] = 0; |
| 1638 | 1638 | i += j; |
| 1639 | 1639 | } |
| 1640 | 1640 | if( !db_exists("SELECT 1 FROM plink WHERE cid=%d AND pid=%d", |
| 1641 | 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)==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 @@ | ||
| 229 | 229 | ); |
| 230 | 230 | return rid; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /* 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) ){ | |
| 235 | 235 | Stmt q; |
| 236 | - char zUuid[HNAME_LEN_MAX+1]; | |
| 236 | + char zUuid[HNAME_MAX+1]; | |
| 237 | 237 | memcpy(zUuid, zTag, nTag+1); |
| 238 | 238 | canonical16(zUuid, nTag); |
| 239 | 239 | rid = 0; |
| 240 | 240 | if( zType[0]=='*' ){ |
| 241 | 241 | db_prepare(&q, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUuid); |
| @@ -350,11 +350,11 @@ | ||
| 350 | 350 | */ |
| 351 | 351 | int name_collisions(const char *zName){ |
| 352 | 352 | int c = 0; /* count of collisions for zName */ |
| 353 | 353 | int nLen; /* length of zName */ |
| 354 | 354 | nLen = strlen(zName); |
| 355 | - if( nLen>=4 && nLen<=HNAME_LEN_MAX && validate16(zName, nLen) ){ | |
| 355 | + if( nLen>=4 && nLen<=HNAME_MAX && validate16(zName, nLen) ){ | |
| 356 | 356 | c = db_int(0, |
| 357 | 357 | "SELECT" |
| 358 | 358 | " (SELECT count(*) FROM ticket" |
| 359 | 359 | " WHERE tkt_uuid GLOB '%q*') +" |
| 360 | 360 | " (SELECT count(*) FROM tag" |
| @@ -664,11 +664,11 @@ | ||
| 664 | 664 | /* |
| 665 | 665 | ** COMMAND: whatis* |
| 666 | 666 | ** |
| 667 | 667 | ** Usage: %fossil whatis NAME |
| 668 | 668 | ** |
| 669 | -** Resolve the symbol NAME into its canonical 40-character SHA1-hash | |
| 669 | +** Resolve the symbol NAME into its canonical artifact hash | |
| 670 | 670 | ** artifact name and provide a description of what role that artifact |
| 671 | 671 | ** plays. |
| 672 | 672 | ** |
| 673 | 673 | ** Options: |
| 674 | 674 | ** |
| @@ -1150,26 +1150,26 @@ | ||
| 1150 | 1150 | */ |
| 1151 | 1151 | static void collision_report(const char *zSql){ |
| 1152 | 1152 | int i, j, kk; |
| 1153 | 1153 | int nHash = 0; |
| 1154 | 1154 | Stmt q; |
| 1155 | - char zPrev[HNAME_LEN_MAX+1]; | |
| 1155 | + char zPrev[HNAME_MAX+1]; | |
| 1156 | 1156 | struct { |
| 1157 | 1157 | int cnt; |
| 1158 | 1158 | 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]; | |
| 1161 | 1161 | memset(aCollide, 0, sizeof(aCollide)); |
| 1162 | 1162 | memset(zPrev, 0, sizeof(zPrev)); |
| 1163 | 1163 | db_prepare(&q,"%s",zSql/*safe-for-%s*/); |
| 1164 | 1164 | while( db_step(&q)==SQLITE_ROW ){ |
| 1165 | 1165 | const char *zUuid = db_column_text(&q,0); |
| 1166 | 1166 | int n = db_column_bytes(&q,0); |
| 1167 | 1167 | int i; |
| 1168 | 1168 | nHash++; |
| 1169 | 1169 | 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 ){ | |
| 1171 | 1171 | if( i>=4 && aCollide[i].cnt<MAX_COLLIDE ){ |
| 1172 | 1172 | aCollide[i].azHit[aCollide[i].cnt] = mprintf("%.*s", i, zPrev); |
| 1173 | 1173 | } |
| 1174 | 1174 | aCollide[i].cnt++; |
| 1175 | 1175 | if( aCollide[i].z[0]==0 ) memcpy(aCollide[i].z, zPrev, n+1); |
| @@ -1178,18 +1178,18 @@ | ||
| 1178 | 1178 | } |
| 1179 | 1179 | db_finalize(&q); |
| 1180 | 1180 | @ <table border=1><thead> |
| 1181 | 1181 | @ <tr><th>Length<th>Instances<th>First Instance</tr> |
| 1182 | 1182 | @ </thead><tbody> |
| 1183 | - for(i=1; i<=HNAME_LEN_MAX; i++){ | |
| 1183 | + for(i=1; i<=HNAME_MAX; i++){ | |
| 1184 | 1184 | if( aCollide[i].cnt==0 ) continue; |
| 1185 | 1185 | @ <tr><td>%d(i)<td>%d(aCollide[i].cnt)<td>%h(aCollide[i].z)</tr> |
| 1186 | 1186 | } |
| 1187 | 1187 | @ </tbody></table> |
| 1188 | 1188 | @ <p>Total number of hashes: %d(nHash)</p> |
| 1189 | 1189 | kk = 0; |
| 1190 | - for(i=HNAME_LEN_MAX; i>=4; i--){ | |
| 1190 | + for(i=HNAME_MAX; i>=4; i--){ | |
| 1191 | 1191 | if( aCollide[i].cnt==0 ) continue; |
| 1192 | 1192 | if( aCollide[i].cnt>200 ) break; |
| 1193 | 1193 | kk += aCollide[i].cnt; |
| 1194 | 1194 | if( aCollide[i].cnt<25 ){ |
| 1195 | 1195 | @ <p>Collisions of length %d(i): |
| 1196 | 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_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 @@ | ||
| 1029 | 1029 | ** |
| 1030 | 1030 | ** |
| 1031 | 1031 | ** This command exports all artifacts of a given repository and |
| 1032 | 1032 | ** writes all artifacts to the file system. The DESTINATION directory |
| 1033 | 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. | |
| 1034 | +** AABBBBBBBBB.. is the 40+ character artifact ID, AA the first 2 characters. | |
| 1035 | 1035 | ** If -L|--prefixlength is given, the length (default 2) of the directory |
| 1036 | 1036 | ** prefix can be set to 0,1,..,9 characters. |
| 1037 | 1037 | ** |
| 1038 | 1038 | ** Options: |
| 1039 | 1039 | ** -R|--repository REPOSITORY deconstruct given REPOSITORY |
| 1040 | 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 |
| --- 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 @@ | ||
| 84 | 84 | } |
| 85 | 85 | zCanonical[j+1] = zCanonical[j] = 0; |
| 86 | 86 | p = zCanonical; |
| 87 | 87 | while( *p ){ |
| 88 | 88 | int nUuid = strlen(p); |
| 89 | - if( hname_validate(p, nUuid)==HNAME_NONE ){ | |
| 89 | + if( !hname_validate(p, nUuid) ){ | |
| 90 | 90 | @ <p class="generalError">Error: Bad artifact IDs.</p> |
| 91 | 91 | fossil_free(zCanonical); |
| 92 | 92 | zCanonical = 0; |
| 93 | 93 | break; |
| 94 | 94 | }else{ |
| @@ -167,18 +167,18 @@ | ||
| 167 | 167 | @ artifact content will be purged from the repository the next time the |
| 168 | 168 | @ repository is rebuilt. A list of shunned artifacts can be seen at the |
| 169 | 169 | @ bottom of this page.</p> |
| 170 | 170 | @ |
| 171 | 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 | |
| 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 | 174 | @ following box and press the "Shun" button. This will cause the artifacts |
| 175 | 175 | @ to be removed from the repository and will prevent the artifacts from being |
| 176 | 176 | @ readded to the repository by subsequent sync operation.</p> |
| 177 | 177 | @ |
| 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> | |
| 180 | 180 | @ |
| 181 | 181 | @ <p>Warning: Shunning should only be used to remove inappropriate content |
| 182 | 182 | @ from the repository. Inappropriate content includes such things as |
| 183 | 183 | @ spam added to Wiki, files that violate copyright or patent agreements, |
| 184 | 184 | @ or artifacts that by design or accident interfere with the processing |
| 185 | 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)==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 @@ | ||
| 40 | 40 | if( content_size(rid, 0)<0 ){ |
| 41 | 41 | return; /* No way to verify phantoms */ |
| 42 | 42 | } |
| 43 | 43 | blob_zero(&uuid); |
| 44 | 44 | 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)) ){ | |
| 46 | 46 | fossil_fatal("not a valid rid: %d", rid); |
| 47 | 47 | } |
| 48 | 48 | if( content_get(rid, &content) ){ |
| 49 | 49 | sha1sum_blob(&content, &hash); |
| 50 | 50 | blob_reset(&content); |
| 51 | 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 |
| --- 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 @@ | ||
| 21 | 21 | #include "vfile.h" |
| 22 | 22 | #include <assert.h> |
| 23 | 23 | #include <sys/types.h> |
| 24 | 24 | |
| 25 | 25 | /* |
| 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. | |
| 28 | 28 | */ |
| 29 | 29 | int fast_uuid_to_rid(const char *zUuid){ |
| 30 | 30 | static Stmt q; |
| 31 | 31 | int rid; |
| 32 | 32 | db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid"); |
| @@ -51,15 +51,15 @@ | ||
| 51 | 51 | ** create a phantom record. A private phantom is created for 2 and |
| 52 | 52 | ** a public phantom is created for 1. |
| 53 | 53 | */ |
| 54 | 54 | int uuid_to_rid(const char *zUuid, int phantomize){ |
| 55 | 55 | int rid, sz; |
| 56 | - char z[HNAME_LEN_MAX+1]; | |
| 56 | + char z[HNAME_MAX+1]; | |
| 57 | 57 | |
| 58 | 58 | 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 */ | |
| 61 | 61 | } |
| 62 | 62 | memcpy(z, zUuid, sz+1); |
| 63 | 63 | canonical16(z, sz); |
| 64 | 64 | rid = fast_uuid_to_rid(z); |
| 65 | 65 | if( rid==0 && phantomize ){ |
| 66 | 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-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 @@ | ||
| 1122 | 1122 | */ |
| 1123 | 1123 | int wiki_technote_to_rid(const char *zETime) { |
| 1124 | 1124 | int rid=0; /* Artifact ID of the tech note */ |
| 1125 | 1125 | int nETime = strlen(zETime); |
| 1126 | 1126 | 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]; | |
| 1129 | 1129 | memcpy(zUuid, zETime, nETime+1); |
| 1130 | 1130 | canonical16(zUuid, nETime); |
| 1131 | 1131 | db_prepare(&q, |
| 1132 | 1132 | "SELECT e.objid" |
| 1133 | 1133 | " FROM event e, tag t" |
| 1134 | 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/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 |
+1
-1
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -1067,11 +1067,11 @@ | ||
| 1067 | 1067 | ** If the input string corresponds to an existing baseline, |
| 1068 | 1068 | ** return true. |
| 1069 | 1069 | */ |
| 1070 | 1070 | static int is_valid_uuid(const char *z){ |
| 1071 | 1071 | int n = strlen(z); |
| 1072 | - if( n<4 || n>HNAME_LEN_MAX ) return 0; | |
| 1072 | + if( n<4 || n>HNAME_MAX ) return 0; | |
| 1073 | 1073 | if( !validate16(z, n) ) return 0; |
| 1074 | 1074 | return 1; |
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | /* |
| 1078 | 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 |
| --- 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 |