Fossil SCM

Fix a bug in the schema definition that prevented new repositories from being created. On the server side, check the authentication hash using the appropriate hash algorithm.

drh 2017-02-28 22:55 fossil-2.0
Commit f7861887d36f0e2c005ba377cd8b31d01990f9bf
2 files changed +1 -1 +6 -5
+1 -1
--- src/schema.c
+++ src/schema.c
@@ -119,11 +119,11 @@
119119
@ --
120120
@ CREATE TABLE alias(
121121
@ hval TEXT, -- Hex-encoded hash value
122122
@ htype ANY, -- Type of hash.
123123
@ rid INTEGER REFERENCES blob, -- Blob that this hash names
124
-@ PRIMARY KEY(hval,htype,id)
124
+@ PRIMARY KEY(hval,htype,rid)
125125
@ ) WITHOUT ROWID;
126126
@ CREATE INDEX alias_rid ON alias(rid);
127127
@
128128
@ -- Information about users
129129
@ --
130130
--- src/schema.c
+++ src/schema.c
@@ -119,11 +119,11 @@
119 @ --
120 @ CREATE TABLE alias(
121 @ hval TEXT, -- Hex-encoded hash value
122 @ htype ANY, -- Type of hash.
123 @ rid INTEGER REFERENCES blob, -- Blob that this hash names
124 @ PRIMARY KEY(hval,htype,id)
125 @ ) WITHOUT ROWID;
126 @ CREATE INDEX alias_rid ON alias(rid);
127 @
128 @ -- Information about users
129 @ --
130
--- src/schema.c
+++ src/schema.c
@@ -119,11 +119,11 @@
119 @ --
120 @ CREATE TABLE alias(
121 @ hval TEXT, -- Hex-encoded hash value
122 @ htype ANY, -- Type of hash.
123 @ rid INTEGER REFERENCES blob, -- Blob that this hash names
124 @ PRIMARY KEY(hval,htype,rid)
125 @ ) WITHOUT ROWID;
126 @ CREATE INDEX alias_rid ON alias(rid);
127 @
128 @ -- Information about users
129 @ --
130
+6 -5
--- src/xfer.c
+++ src/xfer.c
@@ -721,23 +721,24 @@
721721
}
722722
db_finalize(&q);
723723
}
724724
725725
/*
726
-** Compute an SHA1 hash on the tail of pMsg. Verify that it matches the
726
+** Compute an hash on the tail of pMsg. Verify that it matches the
727727
** the hash given in pHash. Return non-zero for an error and 0 on success.
728
+**
729
+** The type of hash computed (SHA1, SHA3-224, SHA3-256) is determined by
730
+** the length of the input hash in pHash.
728731
*/
729732
static int check_tail_hash(Blob *pHash, Blob *pMsg){
730733
Blob tail;
731734
Blob h2;
732735
int rc;
733736
blob_tail(pMsg, &tail);
734
- sha1sum_blob(&tail, &h2);
735
- rc = blob_compare(pHash, &h2);
736
- blob_reset(&h2);
737
+ rc = hname_verify_hash(&tail, blob_buffer(pHash), blob_size(pHash));
737738
blob_reset(&tail);
738
- return rc;
739
+ return rc==HNAME_ERROR;
739740
}
740741
741742
/*
742743
** Check the signature on an application/x-fossil payload received by
743744
** the HTTP server. The signature is a line of the following form:
744745
--- src/xfer.c
+++ src/xfer.c
@@ -721,23 +721,24 @@
721 }
722 db_finalize(&q);
723 }
724
725 /*
726 ** Compute an SHA1 hash on the tail of pMsg. Verify that it matches the
727 ** the hash given in pHash. Return non-zero for an error and 0 on success.
 
 
 
728 */
729 static int check_tail_hash(Blob *pHash, Blob *pMsg){
730 Blob tail;
731 Blob h2;
732 int rc;
733 blob_tail(pMsg, &tail);
734 sha1sum_blob(&tail, &h2);
735 rc = blob_compare(pHash, &h2);
736 blob_reset(&h2);
737 blob_reset(&tail);
738 return rc;
739 }
740
741 /*
742 ** Check the signature on an application/x-fossil payload received by
743 ** the HTTP server. The signature is a line of the following form:
744
--- src/xfer.c
+++ src/xfer.c
@@ -721,23 +721,24 @@
721 }
722 db_finalize(&q);
723 }
724
725 /*
726 ** Compute an hash on the tail of pMsg. Verify that it matches the
727 ** the hash given in pHash. Return non-zero for an error and 0 on success.
728 **
729 ** The type of hash computed (SHA1, SHA3-224, SHA3-256) is determined by
730 ** the length of the input hash in pHash.
731 */
732 static int check_tail_hash(Blob *pHash, Blob *pMsg){
733 Blob tail;
734 Blob h2;
735 int rc;
736 blob_tail(pMsg, &tail);
737 rc = hname_verify_hash(&tail, blob_buffer(pHash), blob_size(pHash));
 
 
738 blob_reset(&tail);
739 return rc==HNAME_ERROR;
740 }
741
742 /*
743 ** Check the signature on an application/x-fossil payload received by
744 ** the HTTP server. The signature is a line of the following form:
745

Keyboard Shortcuts

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