Fossil SCM

Prevent fals-posivitive in fingerprint check, when the current checkout is empty.

jan.nijtmans 2019-10-07 10:07 trunk
Commit fd8816ecf6eeea11adb07e335419535c5d6a0bf4efa22f5eb09184e9dbcb877c
1 file changed +12 -6
+12 -6
--- src/db.c
+++ src/db.c
@@ -4006,16 +4006,18 @@
40064006
** Also set "fingerprint" and "checkout-hash".
40074007
*/
40084008
void db_set_checkout(int rid){
40094009
char *z;
40104010
db_lset_int("checkout", rid);
4011
- z = db_text(0,"SELECT uuid FROM blob WHERE rid=%d",rid);
4012
- db_lset("checkout-hash", z);
4013
- fossil_free(z);
4014
- z = db_fingerprint(0, 1);
4015
- db_lset("fingerprint", z);
4016
- fossil_free(z);
4011
+ if (rid != 0) {
4012
+ z = db_text(0,"SELECT uuid FROM blob WHERE rid=%d",rid);
4013
+ db_lset("checkout-hash", z);
4014
+ fossil_free(z);
4015
+ z = db_fingerprint(0, 1);
4016
+ db_lset("fingerprint", z);
4017
+ fossil_free(z);
4018
+ }
40174019
}
40184020
40194021
/*
40204022
** Verify that the fingerprint recorded in the "fingerprint" entry
40214023
** of the VVAR table matches the fingerprint on the currently
@@ -4026,10 +4028,14 @@
40264028
char *zCkout; /* The fingerprint recorded in the checkout database */
40274029
char *zRepo; /* The fingerprint of the repository */
40284030
int rc; /* Result */
40294031
40304032
zCkout = db_text(0,"SELECT value FROM localdb.vvar WHERE name='fingerprint'");
4033
+ if( !db_lget_int("checkout", 0) ){
4034
+ /* We have an empty checkout, fingerprint is still NULL. */
4035
+ return 2;
4036
+ }
40314037
if( zCkout==0 ){
40324038
/* This is an older checkout that does not record a fingerprint.
40334039
** We have to assume everything is ok */
40344040
return 2;
40354041
}
40364042
--- src/db.c
+++ src/db.c
@@ -4006,16 +4006,18 @@
4006 ** Also set "fingerprint" and "checkout-hash".
4007 */
4008 void db_set_checkout(int rid){
4009 char *z;
4010 db_lset_int("checkout", rid);
4011 z = db_text(0,"SELECT uuid FROM blob WHERE rid=%d",rid);
4012 db_lset("checkout-hash", z);
4013 fossil_free(z);
4014 z = db_fingerprint(0, 1);
4015 db_lset("fingerprint", z);
4016 fossil_free(z);
 
 
4017 }
4018
4019 /*
4020 ** Verify that the fingerprint recorded in the "fingerprint" entry
4021 ** of the VVAR table matches the fingerprint on the currently
@@ -4026,10 +4028,14 @@
4026 char *zCkout; /* The fingerprint recorded in the checkout database */
4027 char *zRepo; /* The fingerprint of the repository */
4028 int rc; /* Result */
4029
4030 zCkout = db_text(0,"SELECT value FROM localdb.vvar WHERE name='fingerprint'");
 
 
 
 
4031 if( zCkout==0 ){
4032 /* This is an older checkout that does not record a fingerprint.
4033 ** We have to assume everything is ok */
4034 return 2;
4035 }
4036
--- src/db.c
+++ src/db.c
@@ -4006,16 +4006,18 @@
4006 ** Also set "fingerprint" and "checkout-hash".
4007 */
4008 void db_set_checkout(int rid){
4009 char *z;
4010 db_lset_int("checkout", rid);
4011 if (rid != 0) {
4012 z = db_text(0,"SELECT uuid FROM blob WHERE rid=%d",rid);
4013 db_lset("checkout-hash", z);
4014 fossil_free(z);
4015 z = db_fingerprint(0, 1);
4016 db_lset("fingerprint", z);
4017 fossil_free(z);
4018 }
4019 }
4020
4021 /*
4022 ** Verify that the fingerprint recorded in the "fingerprint" entry
4023 ** of the VVAR table matches the fingerprint on the currently
@@ -4026,10 +4028,14 @@
4028 char *zCkout; /* The fingerprint recorded in the checkout database */
4029 char *zRepo; /* The fingerprint of the repository */
4030 int rc; /* Result */
4031
4032 zCkout = db_text(0,"SELECT value FROM localdb.vvar WHERE name='fingerprint'");
4033 if( !db_lget_int("checkout", 0) ){
4034 /* We have an empty checkout, fingerprint is still NULL. */
4035 return 2;
4036 }
4037 if( zCkout==0 ){
4038 /* This is an older checkout that does not record a fingerprint.
4039 ** We have to assume everything is ok */
4040 return 2;
4041 }
4042

Keyboard Shortcuts

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