Fossil SCM
On unix, make sure file descriptor 2 is open and file descriptor 3 is not open at the beginning of main(). The first check helps ensure that a assert() will not accidently overwrite a file. The second check verifies that the is_valid_fd() function used by the first check really works.
Commit
4ef3708d8d646f90c9d1c486cfbb2693f19aea75
Parent
24bff454abf7a2e…
1 file changed
+3
+3
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -608,11 +608,14 @@ | ||
| 608 | 608 | g.argc++; |
| 609 | 609 | g.argv = zNewArgv; |
| 610 | 610 | } |
| 611 | 611 | zCmdName = g.argv[1]; |
| 612 | 612 | } |
| 613 | +#ifndef _WIN32 | |
| 613 | 614 | if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open"); |
| 615 | + if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open"); | |
| 616 | +#endif | |
| 614 | 617 | rc = name_search(zCmdName, aCommand, count(aCommand), &idx); |
| 615 | 618 | if( rc==1 ){ |
| 616 | 619 | fossil_fatal("%s: unknown command: %s\n" |
| 617 | 620 | "%s: use \"help\" for more information\n", |
| 618 | 621 | g.argv[0], zCmdName, g.argv[0]); |
| 619 | 622 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -608,11 +608,14 @@ | |
| 608 | g.argc++; |
| 609 | g.argv = zNewArgv; |
| 610 | } |
| 611 | zCmdName = g.argv[1]; |
| 612 | } |
| 613 | if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open"); |
| 614 | rc = name_search(zCmdName, aCommand, count(aCommand), &idx); |
| 615 | if( rc==1 ){ |
| 616 | fossil_fatal("%s: unknown command: %s\n" |
| 617 | "%s: use \"help\" for more information\n", |
| 618 | g.argv[0], zCmdName, g.argv[0]); |
| 619 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -608,11 +608,14 @@ | |
| 608 | g.argc++; |
| 609 | g.argv = zNewArgv; |
| 610 | } |
| 611 | zCmdName = g.argv[1]; |
| 612 | } |
| 613 | #ifndef _WIN32 |
| 614 | if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open"); |
| 615 | if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open"); |
| 616 | #endif |
| 617 | rc = name_search(zCmdName, aCommand, count(aCommand), &idx); |
| 618 | if( rc==1 ){ |
| 619 | fossil_fatal("%s: unknown command: %s\n" |
| 620 | "%s: use \"help\" for more information\n", |
| 621 | g.argv[0], zCmdName, g.argv[0]); |
| 622 |