Fossil SCM
branch, start committing hacking that will hopefully yield fix to this problem: one is allowed to checkout "artifacts" that should not be checkout-able (ie: changes to tickets); trying to check this out is permitted, but results in a segfault
Commit
4fff36610997f7f3b222d981b30d9ae99f177e5d
Parent
879e8c5f32be016…
1 file changed
+33
+33
| --- src/checkout.c | ||
| +++ src/checkout.c | ||
| @@ -43,10 +43,40 @@ | ||
| 43 | 43 | if( vid==0 ) return 2; |
| 44 | 44 | vfile_check_signature(vid); |
| 45 | 45 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 46 | 46 | " OR coalesce(origname!=pathname,0)"); |
| 47 | 47 | } |
| 48 | + | |
| 49 | +/* | |
| 50 | +** Check to see if the requested co is in fact "checkout-able" | |
| 51 | +** Return values: | |
| 52 | +** 0: Not checkout-able (does not exist, or is not an on-disk artifact) | |
| 53 | +** 1: Is checkout-able. | |
| 54 | +*/ | |
| 55 | +int checkoutable(const char *zName){ | |
| 56 | + int rc=1; /* assuming is checkout-able */ | |
| 57 | + Blob uuid; | |
| 58 | + const char *rid=(char *)NULL; | |
| 59 | + Stmt q; // db query | |
| 60 | + char *zSQL; //build-up sql | |
| 61 | + | |
| 62 | + // zSQL = mprintf(); | |
| 63 | + | |
| 64 | + // [create sql statement] | |
| 65 | + // db_prepare(&q,sqlstmt); | |
| 66 | + | |
| 67 | + blob_init(&uuid, zName, -1); | |
| 68 | + if( name_to_uuid(&uuid, 1) ){ | |
| 69 | + fossil_panic(g.zErrMsg); | |
| 70 | + } | |
| 71 | + | |
| 72 | + /* nParent=db_text(0,"select rid from blob where uuid=%s",uuid.nameofobj); */ | |
| 73 | + | |
| 74 | + /* int nParent = db_column_int(q, somenum); */ | |
| 75 | + return rc; | |
| 76 | +} | |
| 77 | + | |
| 48 | 78 | |
| 49 | 79 | /* |
| 50 | 80 | ** Undo the current check-out. Unlink all files from the disk. |
| 51 | 81 | ** Clear the VFILE table. |
| 52 | 82 | */ |
| @@ -157,10 +187,13 @@ | ||
| 157 | 187 | noWrite = find_option("dontwrite",0,0)!=0; |
| 158 | 188 | if( g.argc!=3 ) usage("?--force? VERSION"); |
| 159 | 189 | if( !forceFlag && unsaved_changes()==1 ){ |
| 160 | 190 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 161 | 191 | } |
| 192 | + if(!checkoutable()){ | |
| 193 | + fossil_fatal("the VERSION you requested is not a checkout-able artifact"); | |
| 194 | + } | |
| 162 | 195 | if( forceFlag ){ |
| 163 | 196 | db_multi_exec("DELETE FROM vfile"); |
| 164 | 197 | prior = 0; |
| 165 | 198 | }else{ |
| 166 | 199 | prior = db_lget_int("checkout",0); |
| 167 | 200 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -43,10 +43,40 @@ | |
| 43 | if( vid==0 ) return 2; |
| 44 | vfile_check_signature(vid); |
| 45 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 46 | " OR coalesce(origname!=pathname,0)"); |
| 47 | } |
| 48 | |
| 49 | /* |
| 50 | ** Undo the current check-out. Unlink all files from the disk. |
| 51 | ** Clear the VFILE table. |
| 52 | */ |
| @@ -157,10 +187,13 @@ | |
| 157 | noWrite = find_option("dontwrite",0,0)!=0; |
| 158 | if( g.argc!=3 ) usage("?--force? VERSION"); |
| 159 | if( !forceFlag && unsaved_changes()==1 ){ |
| 160 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 161 | } |
| 162 | if( forceFlag ){ |
| 163 | db_multi_exec("DELETE FROM vfile"); |
| 164 | prior = 0; |
| 165 | }else{ |
| 166 | prior = db_lget_int("checkout",0); |
| 167 |
| --- src/checkout.c | |
| +++ src/checkout.c | |
| @@ -43,10 +43,40 @@ | |
| 43 | if( vid==0 ) return 2; |
| 44 | vfile_check_signature(vid); |
| 45 | return db_exists("SELECT 1 FROM vfile WHERE chnged" |
| 46 | " OR coalesce(origname!=pathname,0)"); |
| 47 | } |
| 48 | |
| 49 | /* |
| 50 | ** Check to see if the requested co is in fact "checkout-able" |
| 51 | ** Return values: |
| 52 | ** 0: Not checkout-able (does not exist, or is not an on-disk artifact) |
| 53 | ** 1: Is checkout-able. |
| 54 | */ |
| 55 | int checkoutable(const char *zName){ |
| 56 | int rc=1; /* assuming is checkout-able */ |
| 57 | Blob uuid; |
| 58 | const char *rid=(char *)NULL; |
| 59 | Stmt q; // db query |
| 60 | char *zSQL; //build-up sql |
| 61 | |
| 62 | // zSQL = mprintf(); |
| 63 | |
| 64 | // [create sql statement] |
| 65 | // db_prepare(&q,sqlstmt); |
| 66 | |
| 67 | blob_init(&uuid, zName, -1); |
| 68 | if( name_to_uuid(&uuid, 1) ){ |
| 69 | fossil_panic(g.zErrMsg); |
| 70 | } |
| 71 | |
| 72 | /* nParent=db_text(0,"select rid from blob where uuid=%s",uuid.nameofobj); */ |
| 73 | |
| 74 | /* int nParent = db_column_int(q, somenum); */ |
| 75 | return rc; |
| 76 | } |
| 77 | |
| 78 | |
| 79 | /* |
| 80 | ** Undo the current check-out. Unlink all files from the disk. |
| 81 | ** Clear the VFILE table. |
| 82 | */ |
| @@ -157,10 +187,13 @@ | |
| 187 | noWrite = find_option("dontwrite",0,0)!=0; |
| 188 | if( g.argc!=3 ) usage("?--force? VERSION"); |
| 189 | if( !forceFlag && unsaved_changes()==1 ){ |
| 190 | fossil_fatal("there are unsaved changes in the current checkout"); |
| 191 | } |
| 192 | if(!checkoutable()){ |
| 193 | fossil_fatal("the VERSION you requested is not a checkout-able artifact"); |
| 194 | } |
| 195 | if( forceFlag ){ |
| 196 | db_multi_exec("DELETE FROM vfile"); |
| 197 | prior = 0; |
| 198 | }else{ |
| 199 | prior = db_lget_int("checkout",0); |
| 200 |