Fossil SCM
Since the intent of the TH1 'hascap' command is that all specified permissions are required (i.e. the first missing permission should stop further checks), correct the loop invariant.
Commit
1c0b1a58c60328c2b5710a9c7ab100f015b05b11
Parent
5915e6f4d4c7eab…
1 file changed
+2
-2
+2
-2
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -636,15 +636,15 @@ | ||
| 636 | 636 | void *p, |
| 637 | 637 | int argc, |
| 638 | 638 | const char **argv, |
| 639 | 639 | int *argl |
| 640 | 640 | ){ |
| 641 | - int rc = 0, i; | |
| 641 | + int rc = 1, i; | |
| 642 | 642 | if( argc<2 ){ |
| 643 | 643 | return Th_WrongNumArgs(interp, "hascap STRING ..."); |
| 644 | 644 | } |
| 645 | - for(i=1; i<argc && rc==0; i++){ | |
| 645 | + for(i=1; rc==1 && i<argc; i++){ | |
| 646 | 646 | rc = login_has_capability((char*)argv[i],argl[i],*(int*)p); |
| 647 | 647 | } |
| 648 | 648 | if( g.thTrace ){ |
| 649 | 649 | Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc); |
| 650 | 650 | } |
| 651 | 651 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -636,15 +636,15 @@ | |
| 636 | void *p, |
| 637 | int argc, |
| 638 | const char **argv, |
| 639 | int *argl |
| 640 | ){ |
| 641 | int rc = 0, i; |
| 642 | if( argc<2 ){ |
| 643 | return Th_WrongNumArgs(interp, "hascap STRING ..."); |
| 644 | } |
| 645 | for(i=1; i<argc && rc==0; i++){ |
| 646 | rc = login_has_capability((char*)argv[i],argl[i],*(int*)p); |
| 647 | } |
| 648 | if( g.thTrace ){ |
| 649 | Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc); |
| 650 | } |
| 651 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -636,15 +636,15 @@ | |
| 636 | void *p, |
| 637 | int argc, |
| 638 | const char **argv, |
| 639 | int *argl |
| 640 | ){ |
| 641 | int rc = 1, i; |
| 642 | if( argc<2 ){ |
| 643 | return Th_WrongNumArgs(interp, "hascap STRING ..."); |
| 644 | } |
| 645 | for(i=1; rc==1 && i<argc; i++){ |
| 646 | rc = login_has_capability((char*)argv[i],argl[i],*(int*)p); |
| 647 | } |
| 648 | if( g.thTrace ){ |
| 649 | Th_Trace("[hascap %#h] => %d<br />\n", argl[1], argv[1], rc); |
| 650 | } |
| 651 |