Fossil SCM
Reduce fossil_panic() calls to those indicating bugs and internal errors. Also clarify effects and purposes of fossil_fatal() vs. fossil_panic().
Commit
91a4652f22101a1cc558c350e9ea0a7e9c3f6da138822fa63cced1dc3107d385
Parent
1efa8d7f18e8bec…
15 files changed
+3
-3
+1
-1
+5
-5
+5
-5
+3
-3
+3
-3
+1
-1
+1
-1
+2
-2
+11
-6
+1
-1
+1
-1
+7
-7
+1
-1
+5
-4
+3
-3
| --- src/bundle.c | ||
| +++ src/bundle.c | ||
| @@ -60,11 +60,11 @@ | ||
| 60 | 60 | if( !doInit && file_size(zFile, ExtFILE)<0 ){ |
| 61 | 61 | fossil_fatal("no such file: %s", zFile); |
| 62 | 62 | } |
| 63 | 63 | assert( g.db ); |
| 64 | 64 | zSql = sqlite3_mprintf("ATTACH %Q AS %Q", zFile, zBName); |
| 65 | - if( zSql==0 ) fossil_panic("out of memory"); | |
| 65 | + if( zSql==0 ) fossil_fatal("out of memory"); | |
| 66 | 66 | rc = sqlite3_exec(g.db, zSql, 0, 0, &zErrMsg); |
| 67 | 67 | sqlite3_free(zSql); |
| 68 | 68 | if( rc!=SQLITE_OK || zErrMsg ){ |
| 69 | 69 | if( zErrMsg==0 ) zErrMsg = (char*)sqlite3_errmsg(g.db); |
| 70 | 70 | fossil_fatal("not a valid bundle: %s", zFile); |
| @@ -73,18 +73,18 @@ | ||
| 73 | 73 | db_multi_exec(zBundleInit /*works-like:"%w%w"*/, zBName, zBName); |
| 74 | 74 | }else{ |
| 75 | 75 | sqlite3_stmt *pStmt; |
| 76 | 76 | zSql = sqlite3_mprintf("SELECT bcname, bcvalue" |
| 77 | 77 | " FROM \"%w\".bconfig", zBName); |
| 78 | - if( zSql==0 ) fossil_panic("out of memory"); | |
| 78 | + if( zSql==0 ) fossil_fatal("out of memory"); | |
| 79 | 79 | rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, 0); |
| 80 | 80 | if( rc ) fossil_fatal("not a valid bundle: %s", zFile); |
| 81 | 81 | sqlite3_free(zSql); |
| 82 | 82 | sqlite3_finalize(pStmt); |
| 83 | 83 | zSql = sqlite3_mprintf("SELECT blobid, uuid, sz, delta, notes, data" |
| 84 | 84 | " FROM \"%w\".bblob", zBName); |
| 85 | - if( zSql==0 ) fossil_panic("out of memory"); | |
| 85 | + if( zSql==0 ) fossil_fatal("out of memory"); | |
| 86 | 86 | rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, 0); |
| 87 | 87 | if( rc ) fossil_fatal("not a valid bundle: %s", zFile); |
| 88 | 88 | sqlite3_free(zSql); |
| 89 | 89 | sqlite3_finalize(pStmt); |
| 90 | 90 | } |
| 91 | 91 |
| --- src/bundle.c | |
| +++ src/bundle.c | |
| @@ -60,11 +60,11 @@ | |
| 60 | if( !doInit && file_size(zFile, ExtFILE)<0 ){ |
| 61 | fossil_fatal("no such file: %s", zFile); |
| 62 | } |
| 63 | assert( g.db ); |
| 64 | zSql = sqlite3_mprintf("ATTACH %Q AS %Q", zFile, zBName); |
| 65 | if( zSql==0 ) fossil_panic("out of memory"); |
| 66 | rc = sqlite3_exec(g.db, zSql, 0, 0, &zErrMsg); |
| 67 | sqlite3_free(zSql); |
| 68 | if( rc!=SQLITE_OK || zErrMsg ){ |
| 69 | if( zErrMsg==0 ) zErrMsg = (char*)sqlite3_errmsg(g.db); |
| 70 | fossil_fatal("not a valid bundle: %s", zFile); |
| @@ -73,18 +73,18 @@ | |
| 73 | db_multi_exec(zBundleInit /*works-like:"%w%w"*/, zBName, zBName); |
| 74 | }else{ |
| 75 | sqlite3_stmt *pStmt; |
| 76 | zSql = sqlite3_mprintf("SELECT bcname, bcvalue" |
| 77 | " FROM \"%w\".bconfig", zBName); |
| 78 | if( zSql==0 ) fossil_panic("out of memory"); |
| 79 | rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, 0); |
| 80 | if( rc ) fossil_fatal("not a valid bundle: %s", zFile); |
| 81 | sqlite3_free(zSql); |
| 82 | sqlite3_finalize(pStmt); |
| 83 | zSql = sqlite3_mprintf("SELECT blobid, uuid, sz, delta, notes, data" |
| 84 | " FROM \"%w\".bblob", zBName); |
| 85 | if( zSql==0 ) fossil_panic("out of memory"); |
| 86 | rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, 0); |
| 87 | if( rc ) fossil_fatal("not a valid bundle: %s", zFile); |
| 88 | sqlite3_free(zSql); |
| 89 | sqlite3_finalize(pStmt); |
| 90 | } |
| 91 |
| --- src/bundle.c | |
| +++ src/bundle.c | |
| @@ -60,11 +60,11 @@ | |
| 60 | if( !doInit && file_size(zFile, ExtFILE)<0 ){ |
| 61 | fossil_fatal("no such file: %s", zFile); |
| 62 | } |
| 63 | assert( g.db ); |
| 64 | zSql = sqlite3_mprintf("ATTACH %Q AS %Q", zFile, zBName); |
| 65 | if( zSql==0 ) fossil_fatal("out of memory"); |
| 66 | rc = sqlite3_exec(g.db, zSql, 0, 0, &zErrMsg); |
| 67 | sqlite3_free(zSql); |
| 68 | if( rc!=SQLITE_OK || zErrMsg ){ |
| 69 | if( zErrMsg==0 ) zErrMsg = (char*)sqlite3_errmsg(g.db); |
| 70 | fossil_fatal("not a valid bundle: %s", zFile); |
| @@ -73,18 +73,18 @@ | |
| 73 | db_multi_exec(zBundleInit /*works-like:"%w%w"*/, zBName, zBName); |
| 74 | }else{ |
| 75 | sqlite3_stmt *pStmt; |
| 76 | zSql = sqlite3_mprintf("SELECT bcname, bcvalue" |
| 77 | " FROM \"%w\".bconfig", zBName); |
| 78 | if( zSql==0 ) fossil_fatal("out of memory"); |
| 79 | rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, 0); |
| 80 | if( rc ) fossil_fatal("not a valid bundle: %s", zFile); |
| 81 | sqlite3_free(zSql); |
| 82 | sqlite3_finalize(pStmt); |
| 83 | zSql = sqlite3_mprintf("SELECT blobid, uuid, sz, delta, notes, data" |
| 84 | " FROM \"%w\".bblob", zBName); |
| 85 | if( zSql==0 ) fossil_fatal("out of memory"); |
| 86 | rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, 0); |
| 87 | if( rc ) fossil_fatal("not a valid bundle: %s", zFile); |
| 88 | sqlite3_free(zSql); |
| 89 | sqlite3_finalize(pStmt); |
| 90 | } |
| 91 |
+1
-1
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -1836,11 +1836,11 @@ | ||
| 1836 | 1836 | if( nCycles==0 ){ |
| 1837 | 1837 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 1838 | 1838 | g.zIpAddr = fossil_strdup(zIpAddr); |
| 1839 | 1839 | } |
| 1840 | 1840 | }else{ |
| 1841 | - fossil_panic("missing SSH IP address"); | |
| 1841 | + fossil_fatal("missing SSH IP address"); | |
| 1842 | 1842 | } |
| 1843 | 1843 | if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){ |
| 1844 | 1844 | malformed_request("missing HTTP header"); |
| 1845 | 1845 | } |
| 1846 | 1846 | cgi_trace(zLine); |
| 1847 | 1847 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -1836,11 +1836,11 @@ | |
| 1836 | if( nCycles==0 ){ |
| 1837 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 1838 | g.zIpAddr = fossil_strdup(zIpAddr); |
| 1839 | } |
| 1840 | }else{ |
| 1841 | fossil_panic("missing SSH IP address"); |
| 1842 | } |
| 1843 | if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){ |
| 1844 | malformed_request("missing HTTP header"); |
| 1845 | } |
| 1846 | cgi_trace(zLine); |
| 1847 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -1836,11 +1836,11 @@ | |
| 1836 | if( nCycles==0 ){ |
| 1837 | cgi_setenv("REMOTE_ADDR", zIpAddr); |
| 1838 | g.zIpAddr = fossil_strdup(zIpAddr); |
| 1839 | } |
| 1840 | }else{ |
| 1841 | fossil_fatal("missing SSH IP address"); |
| 1842 | } |
| 1843 | if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){ |
| 1844 | malformed_request("missing HTTP header"); |
| 1845 | } |
| 1846 | cgi_trace(zLine); |
| 1847 |
M
src/db.c
+5
-5
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -456,16 +456,16 @@ | ||
| 456 | 456 | } |
| 457 | 457 | db.protectMask = db.aProtect[--db.nProtect]; |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | /* |
| 461 | -** Verify that the desired database write pertections are in place. | |
| 461 | +** Verify that the desired database write protections are in place. | |
| 462 | 462 | ** Throw a fatal error if not. |
| 463 | 463 | */ |
| 464 | 464 | void db_assert_protected(unsigned flags){ |
| 465 | 465 | if( (flags & db.protectMask)!=flags ){ |
| 466 | - fossil_panic("missing database write protection bits: %02x", | |
| 466 | + fossil_fatal("missing database write protection bits: %02x", | |
| 467 | 467 | flags & ~db.protectMask); |
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /* |
| @@ -1831,11 +1831,11 @@ | ||
| 1831 | 1831 | |
| 1832 | 1832 | /* The HOME variable is required in order to continue. |
| 1833 | 1833 | */ |
| 1834 | 1834 | if( zHome==0 ){ |
| 1835 | 1835 | if( isOptional ) return 0; |
| 1836 | - fossil_panic("cannot locate home directory - please set one of the " | |
| 1836 | + fossil_fatal("cannot locate home directory - please set one of the " | |
| 1837 | 1837 | "FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment " |
| 1838 | 1838 | "variables"); |
| 1839 | 1839 | } |
| 1840 | 1840 | |
| 1841 | 1841 | /* Step 4: If $HOME/.config is a directory -> $HOME/.config/fossil.db |
| @@ -1881,17 +1881,17 @@ | ||
| 1881 | 1881 | } |
| 1882 | 1882 | rc = file_access(zHome, W_OK); |
| 1883 | 1883 | fossil_free(zHome); |
| 1884 | 1884 | if( rc ){ |
| 1885 | 1885 | if( isOptional ) return 0; |
| 1886 | - fossil_panic("home directory \"%s\" must be writeable", zHome); | |
| 1886 | + fossil_fatal("home directory \"%s\" must be writeable", zHome); | |
| 1887 | 1887 | } |
| 1888 | 1888 | db_init_database(zDbName, zConfigSchema, (char*)0); |
| 1889 | 1889 | } |
| 1890 | 1890 | if( file_access(zDbName, W_OK) ){ |
| 1891 | 1891 | if( isOptional ) return 0; |
| 1892 | - fossil_panic("configuration file %s must be writeable", zDbName); | |
| 1892 | + fossil_fatal("configuration file %s must be writeable", zDbName); | |
| 1893 | 1893 | } |
| 1894 | 1894 | if( useAttach ){ |
| 1895 | 1895 | db_open_or_attach(zDbName, "configdb"); |
| 1896 | 1896 | g.dbConfig = 0; |
| 1897 | 1897 | }else{ |
| 1898 | 1898 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -456,16 +456,16 @@ | |
| 456 | } |
| 457 | db.protectMask = db.aProtect[--db.nProtect]; |
| 458 | } |
| 459 | |
| 460 | /* |
| 461 | ** Verify that the desired database write pertections are in place. |
| 462 | ** Throw a fatal error if not. |
| 463 | */ |
| 464 | void db_assert_protected(unsigned flags){ |
| 465 | if( (flags & db.protectMask)!=flags ){ |
| 466 | fossil_panic("missing database write protection bits: %02x", |
| 467 | flags & ~db.protectMask); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | /* |
| @@ -1831,11 +1831,11 @@ | |
| 1831 | |
| 1832 | /* The HOME variable is required in order to continue. |
| 1833 | */ |
| 1834 | if( zHome==0 ){ |
| 1835 | if( isOptional ) return 0; |
| 1836 | fossil_panic("cannot locate home directory - please set one of the " |
| 1837 | "FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment " |
| 1838 | "variables"); |
| 1839 | } |
| 1840 | |
| 1841 | /* Step 4: If $HOME/.config is a directory -> $HOME/.config/fossil.db |
| @@ -1881,17 +1881,17 @@ | |
| 1881 | } |
| 1882 | rc = file_access(zHome, W_OK); |
| 1883 | fossil_free(zHome); |
| 1884 | if( rc ){ |
| 1885 | if( isOptional ) return 0; |
| 1886 | fossil_panic("home directory \"%s\" must be writeable", zHome); |
| 1887 | } |
| 1888 | db_init_database(zDbName, zConfigSchema, (char*)0); |
| 1889 | } |
| 1890 | if( file_access(zDbName, W_OK) ){ |
| 1891 | if( isOptional ) return 0; |
| 1892 | fossil_panic("configuration file %s must be writeable", zDbName); |
| 1893 | } |
| 1894 | if( useAttach ){ |
| 1895 | db_open_or_attach(zDbName, "configdb"); |
| 1896 | g.dbConfig = 0; |
| 1897 | }else{ |
| 1898 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -456,16 +456,16 @@ | |
| 456 | } |
| 457 | db.protectMask = db.aProtect[--db.nProtect]; |
| 458 | } |
| 459 | |
| 460 | /* |
| 461 | ** Verify that the desired database write protections are in place. |
| 462 | ** Throw a fatal error if not. |
| 463 | */ |
| 464 | void db_assert_protected(unsigned flags){ |
| 465 | if( (flags & db.protectMask)!=flags ){ |
| 466 | fossil_fatal("missing database write protection bits: %02x", |
| 467 | flags & ~db.protectMask); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | /* |
| @@ -1831,11 +1831,11 @@ | |
| 1831 | |
| 1832 | /* The HOME variable is required in order to continue. |
| 1833 | */ |
| 1834 | if( zHome==0 ){ |
| 1835 | if( isOptional ) return 0; |
| 1836 | fossil_fatal("cannot locate home directory - please set one of the " |
| 1837 | "FOSSIL_HOME, XDG_CONFIG_HOME, or HOME environment " |
| 1838 | "variables"); |
| 1839 | } |
| 1840 | |
| 1841 | /* Step 4: If $HOME/.config is a directory -> $HOME/.config/fossil.db |
| @@ -1881,17 +1881,17 @@ | |
| 1881 | } |
| 1882 | rc = file_access(zHome, W_OK); |
| 1883 | fossil_free(zHome); |
| 1884 | if( rc ){ |
| 1885 | if( isOptional ) return 0; |
| 1886 | fossil_fatal("home directory \"%s\" must be writeable", zHome); |
| 1887 | } |
| 1888 | db_init_database(zDbName, zConfigSchema, (char*)0); |
| 1889 | } |
| 1890 | if( file_access(zDbName, W_OK) ){ |
| 1891 | if( isOptional ) return 0; |
| 1892 | fossil_fatal("configuration file %s must be writeable", zDbName); |
| 1893 | } |
| 1894 | if( useAttach ){ |
| 1895 | db_open_or_attach(zDbName, "configdb"); |
| 1896 | g.dbConfig = 0; |
| 1897 | }else{ |
| 1898 |
+5
-5
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -386,14 +386,14 @@ | ||
| 386 | 386 | ** and return non-zero. If everything is ok, return zero. |
| 387 | 387 | */ |
| 388 | 388 | int file_unsafe_in_tree_path(const char *zFile){ |
| 389 | 389 | int n; |
| 390 | 390 | if( !file_is_absolute_path(zFile) ){ |
| 391 | - fossil_panic("%s is not an absolute pathname",zFile); | |
| 391 | + fossil_fatal("%s is not an absolute pathname",zFile); | |
| 392 | 392 | } |
| 393 | 393 | if( fossil_strnicmp(g.zLocalRoot, zFile, (int)strlen(g.zLocalRoot)) ){ |
| 394 | - fossil_panic("%s is not a prefix of %s", g.zLocalRoot, zFile); | |
| 394 | + fossil_fatal("%s is not a prefix of %s", g.zLocalRoot, zFile); | |
| 395 | 395 | } |
| 396 | 396 | n = file_nondir_objects_on_path(g.zLocalRoot, zFile); |
| 397 | 397 | if( n ){ |
| 398 | 398 | fossil_warning("cannot write to %s because non-directory object %.*s" |
| 399 | 399 | " is in the way", zFile, n, zFile); |
| @@ -1148,13 +1148,13 @@ | ||
| 1148 | 1148 | #ifdef _WIN32 |
| 1149 | 1149 | win32_getcwd(zBuf, nBuf); |
| 1150 | 1150 | #else |
| 1151 | 1151 | if( getcwd(zBuf, nBuf-1)==0 ){ |
| 1152 | 1152 | if( errno==ERANGE ){ |
| 1153 | - fossil_panic("pwd too big: max %d", nBuf-1); | |
| 1153 | + fossil_fatal("pwd too big: max %d", nBuf-1); | |
| 1154 | 1154 | }else{ |
| 1155 | - fossil_panic("cannot find current working directory; %s", | |
| 1155 | + fossil_fatal("cannot find current working directory; %s", | |
| 1156 | 1156 | strerror(errno)); |
| 1157 | 1157 | } |
| 1158 | 1158 | } |
| 1159 | 1159 | #endif |
| 1160 | 1160 | return zBuf==zTemp ? fossil_strdup(zBuf) : zBuf; |
| @@ -1823,11 +1823,11 @@ | ||
| 1823 | 1823 | nBasis = 6; |
| 1824 | 1824 | zBasis = "fossil"; |
| 1825 | 1825 | } |
| 1826 | 1826 | do{ |
| 1827 | 1827 | blob_zero(pBuf); |
| 1828 | - if( cnt++>20 ) fossil_panic("cannot generate a temporary filename"); | |
| 1828 | + if( cnt++>20 ) fossil_fatal("cannot generate a temporary filename"); | |
| 1829 | 1829 | if( zTag==0 ){ |
| 1830 | 1830 | sqlite3_randomness(15, zRand); |
| 1831 | 1831 | for(i=0; i<15; i++){ |
| 1832 | 1832 | zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ]; |
| 1833 | 1833 | } |
| 1834 | 1834 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -386,14 +386,14 @@ | |
| 386 | ** and return non-zero. If everything is ok, return zero. |
| 387 | */ |
| 388 | int file_unsafe_in_tree_path(const char *zFile){ |
| 389 | int n; |
| 390 | if( !file_is_absolute_path(zFile) ){ |
| 391 | fossil_panic("%s is not an absolute pathname",zFile); |
| 392 | } |
| 393 | if( fossil_strnicmp(g.zLocalRoot, zFile, (int)strlen(g.zLocalRoot)) ){ |
| 394 | fossil_panic("%s is not a prefix of %s", g.zLocalRoot, zFile); |
| 395 | } |
| 396 | n = file_nondir_objects_on_path(g.zLocalRoot, zFile); |
| 397 | if( n ){ |
| 398 | fossil_warning("cannot write to %s because non-directory object %.*s" |
| 399 | " is in the way", zFile, n, zFile); |
| @@ -1148,13 +1148,13 @@ | |
| 1148 | #ifdef _WIN32 |
| 1149 | win32_getcwd(zBuf, nBuf); |
| 1150 | #else |
| 1151 | if( getcwd(zBuf, nBuf-1)==0 ){ |
| 1152 | if( errno==ERANGE ){ |
| 1153 | fossil_panic("pwd too big: max %d", nBuf-1); |
| 1154 | }else{ |
| 1155 | fossil_panic("cannot find current working directory; %s", |
| 1156 | strerror(errno)); |
| 1157 | } |
| 1158 | } |
| 1159 | #endif |
| 1160 | return zBuf==zTemp ? fossil_strdup(zBuf) : zBuf; |
| @@ -1823,11 +1823,11 @@ | |
| 1823 | nBasis = 6; |
| 1824 | zBasis = "fossil"; |
| 1825 | } |
| 1826 | do{ |
| 1827 | blob_zero(pBuf); |
| 1828 | if( cnt++>20 ) fossil_panic("cannot generate a temporary filename"); |
| 1829 | if( zTag==0 ){ |
| 1830 | sqlite3_randomness(15, zRand); |
| 1831 | for(i=0; i<15; i++){ |
| 1832 | zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ]; |
| 1833 | } |
| 1834 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -386,14 +386,14 @@ | |
| 386 | ** and return non-zero. If everything is ok, return zero. |
| 387 | */ |
| 388 | int file_unsafe_in_tree_path(const char *zFile){ |
| 389 | int n; |
| 390 | if( !file_is_absolute_path(zFile) ){ |
| 391 | fossil_fatal("%s is not an absolute pathname",zFile); |
| 392 | } |
| 393 | if( fossil_strnicmp(g.zLocalRoot, zFile, (int)strlen(g.zLocalRoot)) ){ |
| 394 | fossil_fatal("%s is not a prefix of %s", g.zLocalRoot, zFile); |
| 395 | } |
| 396 | n = file_nondir_objects_on_path(g.zLocalRoot, zFile); |
| 397 | if( n ){ |
| 398 | fossil_warning("cannot write to %s because non-directory object %.*s" |
| 399 | " is in the way", zFile, n, zFile); |
| @@ -1148,13 +1148,13 @@ | |
| 1148 | #ifdef _WIN32 |
| 1149 | win32_getcwd(zBuf, nBuf); |
| 1150 | #else |
| 1151 | if( getcwd(zBuf, nBuf-1)==0 ){ |
| 1152 | if( errno==ERANGE ){ |
| 1153 | fossil_fatal("pwd too big: max %d", nBuf-1); |
| 1154 | }else{ |
| 1155 | fossil_fatal("cannot find current working directory; %s", |
| 1156 | strerror(errno)); |
| 1157 | } |
| 1158 | } |
| 1159 | #endif |
| 1160 | return zBuf==zTemp ? fossil_strdup(zBuf) : zBuf; |
| @@ -1823,11 +1823,11 @@ | |
| 1823 | nBasis = 6; |
| 1824 | zBasis = "fossil"; |
| 1825 | } |
| 1826 | do{ |
| 1827 | blob_zero(pBuf); |
| 1828 | if( cnt++>20 ) fossil_fatal("cannot generate a temporary filename"); |
| 1829 | if( zTag==0 ){ |
| 1830 | sqlite3_randomness(15, zRand); |
| 1831 | for(i=0; i<15; i++){ |
| 1832 | zRand[i] = (char)zChars[ ((unsigned char)zRand[i])%(sizeof(zChars)-1) ]; |
| 1833 | } |
| 1834 |
+3
-3
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -116,11 +116,11 @@ | ||
| 116 | 116 | X509_STORE_set_default_paths(SSL_CTX_get_cert_store(sslCtx)); |
| 117 | 117 | }else{ |
| 118 | 118 | /* User has specified a CA location, make sure it exists and use it */ |
| 119 | 119 | switch( file_isdir(zCaSetting, ExtFILE) ){ |
| 120 | 120 | case 0: { /* doesn't exist */ |
| 121 | - fossil_panic("ssl-ca-location is set to '%s', " | |
| 121 | + fossil_fatal("ssl-ca-location is set to '%s', " | |
| 122 | 122 | "but is not a file or directory", zCaSetting); |
| 123 | 123 | break; |
| 124 | 124 | } |
| 125 | 125 | case 1: { /* directory */ |
| 126 | 126 | zCaDirectory = zCaSetting; |
| @@ -130,11 +130,11 @@ | ||
| 130 | 130 | zCaFile = zCaSetting; |
| 131 | 131 | break; |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | if( SSL_CTX_load_verify_locations(sslCtx, zCaFile, zCaDirectory)==0 ){ |
| 135 | - fossil_panic("Failed to use CA root certificates from " | |
| 135 | + fossil_fatal("Failed to use CA root certificates from " | |
| 136 | 136 | "ssl-ca-location '%s'", zCaSetting); |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /* Load client SSL identity, preferring the filename specified on the |
| @@ -146,11 +146,11 @@ | ||
| 146 | 146 | } |
| 147 | 147 | if( identityFile!=0 && identityFile[0]!='\0' ){ |
| 148 | 148 | if( SSL_CTX_use_certificate_file(sslCtx,identityFile,SSL_FILETYPE_PEM)!=1 |
| 149 | 149 | || SSL_CTX_use_PrivateKey_file(sslCtx,identityFile,SSL_FILETYPE_PEM)!=1 |
| 150 | 150 | ){ |
| 151 | - fossil_panic("Could not load SSL identity from %s", identityFile); | |
| 151 | + fossil_fatal("Could not load SSL identity from %s", identityFile); | |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | /* Register a callback to tell the user what to do when the server asks |
| 155 | 155 | ** for a cert */ |
| 156 | 156 | SSL_CTX_set_client_cert_cb(sslCtx, ssl_client_cert_callback); |
| 157 | 157 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -116,11 +116,11 @@ | |
| 116 | X509_STORE_set_default_paths(SSL_CTX_get_cert_store(sslCtx)); |
| 117 | }else{ |
| 118 | /* User has specified a CA location, make sure it exists and use it */ |
| 119 | switch( file_isdir(zCaSetting, ExtFILE) ){ |
| 120 | case 0: { /* doesn't exist */ |
| 121 | fossil_panic("ssl-ca-location is set to '%s', " |
| 122 | "but is not a file or directory", zCaSetting); |
| 123 | break; |
| 124 | } |
| 125 | case 1: { /* directory */ |
| 126 | zCaDirectory = zCaSetting; |
| @@ -130,11 +130,11 @@ | |
| 130 | zCaFile = zCaSetting; |
| 131 | break; |
| 132 | } |
| 133 | } |
| 134 | if( SSL_CTX_load_verify_locations(sslCtx, zCaFile, zCaDirectory)==0 ){ |
| 135 | fossil_panic("Failed to use CA root certificates from " |
| 136 | "ssl-ca-location '%s'", zCaSetting); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /* Load client SSL identity, preferring the filename specified on the |
| @@ -146,11 +146,11 @@ | |
| 146 | } |
| 147 | if( identityFile!=0 && identityFile[0]!='\0' ){ |
| 148 | if( SSL_CTX_use_certificate_file(sslCtx,identityFile,SSL_FILETYPE_PEM)!=1 |
| 149 | || SSL_CTX_use_PrivateKey_file(sslCtx,identityFile,SSL_FILETYPE_PEM)!=1 |
| 150 | ){ |
| 151 | fossil_panic("Could not load SSL identity from %s", identityFile); |
| 152 | } |
| 153 | } |
| 154 | /* Register a callback to tell the user what to do when the server asks |
| 155 | ** for a cert */ |
| 156 | SSL_CTX_set_client_cert_cb(sslCtx, ssl_client_cert_callback); |
| 157 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -116,11 +116,11 @@ | |
| 116 | X509_STORE_set_default_paths(SSL_CTX_get_cert_store(sslCtx)); |
| 117 | }else{ |
| 118 | /* User has specified a CA location, make sure it exists and use it */ |
| 119 | switch( file_isdir(zCaSetting, ExtFILE) ){ |
| 120 | case 0: { /* doesn't exist */ |
| 121 | fossil_fatal("ssl-ca-location is set to '%s', " |
| 122 | "but is not a file or directory", zCaSetting); |
| 123 | break; |
| 124 | } |
| 125 | case 1: { /* directory */ |
| 126 | zCaDirectory = zCaSetting; |
| @@ -130,11 +130,11 @@ | |
| 130 | zCaFile = zCaSetting; |
| 131 | break; |
| 132 | } |
| 133 | } |
| 134 | if( SSL_CTX_load_verify_locations(sslCtx, zCaFile, zCaDirectory)==0 ){ |
| 135 | fossil_fatal("Failed to use CA root certificates from " |
| 136 | "ssl-ca-location '%s'", zCaSetting); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /* Load client SSL identity, preferring the filename specified on the |
| @@ -146,11 +146,11 @@ | |
| 146 | } |
| 147 | if( identityFile!=0 && identityFile[0]!='\0' ){ |
| 148 | if( SSL_CTX_use_certificate_file(sslCtx,identityFile,SSL_FILETYPE_PEM)!=1 |
| 149 | || SSL_CTX_use_PrivateKey_file(sslCtx,identityFile,SSL_FILETYPE_PEM)!=1 |
| 150 | ){ |
| 151 | fossil_fatal("Could not load SSL identity from %s", identityFile); |
| 152 | } |
| 153 | } |
| 154 | /* Register a callback to tell the user what to do when the server asks |
| 155 | ** for a cert */ |
| 156 | SSL_CTX_set_client_cert_cb(sslCtx, ssl_client_cert_callback); |
| 157 |
+3
-3
| --- src/http_transport.c | ||
| +++ src/http_transport.c | ||
| @@ -127,19 +127,19 @@ | ||
| 127 | 127 | fossil_free(zHost); |
| 128 | 128 | }else{ |
| 129 | 129 | blob_append_escaped_arg(&zCmd, pUrlData->name); |
| 130 | 130 | } |
| 131 | 131 | if( !is_safe_fossil_command(pUrlData->fossil) ){ |
| 132 | - fossil_panic("the ssh:// URL is asking to run an unsafe command [%s] on " | |
| 132 | + fossil_fatal("the ssh:// URL is asking to run an unsafe command [%s] on " | |
| 133 | 133 | "the server.", pUrlData->fossil); |
| 134 | 134 | } |
| 135 | 135 | blob_append_escaped_arg(&zCmd, pUrlData->fossil); |
| 136 | 136 | blob_append(&zCmd, " test-http", 10); |
| 137 | 137 | if( pUrlData->path && pUrlData->path[0] ){ |
| 138 | 138 | blob_append_escaped_arg(&zCmd, pUrlData->path); |
| 139 | 139 | }else{ |
| 140 | - fossil_panic("ssh:// URI does not specify a path to the repository"); | |
| 140 | + fossil_fatal("ssh:// URI does not specify a path to the repository"); | |
| 141 | 141 | } |
| 142 | 142 | if( g.fSshTrace ){ |
| 143 | 143 | fossil_print("%s\n", blob_str(&zCmd)); /* Show the whole SSH command */ |
| 144 | 144 | } |
| 145 | 145 | popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid, 0); |
| @@ -181,11 +181,11 @@ | ||
| 181 | 181 | g.zRepositoryName, iRandId); |
| 182 | 182 | transport.zInFile = mprintf("%s-%llu-in.http", |
| 183 | 183 | g.zRepositoryName, iRandId); |
| 184 | 184 | transport.pFile = fossil_fopen(transport.zOutFile, "wb"); |
| 185 | 185 | if( transport.pFile==0 ){ |
| 186 | - fossil_panic("cannot output temporary file: %s", transport.zOutFile); | |
| 186 | + fossil_fatal("cannot output temporary file: %s", transport.zOutFile); | |
| 187 | 187 | } |
| 188 | 188 | transport.isOpen = 1; |
| 189 | 189 | }else{ |
| 190 | 190 | rc = socket_open(pUrlData); |
| 191 | 191 | if( rc==0 ) transport.isOpen = 1; |
| 192 | 192 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -127,19 +127,19 @@ | |
| 127 | fossil_free(zHost); |
| 128 | }else{ |
| 129 | blob_append_escaped_arg(&zCmd, pUrlData->name); |
| 130 | } |
| 131 | if( !is_safe_fossil_command(pUrlData->fossil) ){ |
| 132 | fossil_panic("the ssh:// URL is asking to run an unsafe command [%s] on " |
| 133 | "the server.", pUrlData->fossil); |
| 134 | } |
| 135 | blob_append_escaped_arg(&zCmd, pUrlData->fossil); |
| 136 | blob_append(&zCmd, " test-http", 10); |
| 137 | if( pUrlData->path && pUrlData->path[0] ){ |
| 138 | blob_append_escaped_arg(&zCmd, pUrlData->path); |
| 139 | }else{ |
| 140 | fossil_panic("ssh:// URI does not specify a path to the repository"); |
| 141 | } |
| 142 | if( g.fSshTrace ){ |
| 143 | fossil_print("%s\n", blob_str(&zCmd)); /* Show the whole SSH command */ |
| 144 | } |
| 145 | popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid, 0); |
| @@ -181,11 +181,11 @@ | |
| 181 | g.zRepositoryName, iRandId); |
| 182 | transport.zInFile = mprintf("%s-%llu-in.http", |
| 183 | g.zRepositoryName, iRandId); |
| 184 | transport.pFile = fossil_fopen(transport.zOutFile, "wb"); |
| 185 | if( transport.pFile==0 ){ |
| 186 | fossil_panic("cannot output temporary file: %s", transport.zOutFile); |
| 187 | } |
| 188 | transport.isOpen = 1; |
| 189 | }else{ |
| 190 | rc = socket_open(pUrlData); |
| 191 | if( rc==0 ) transport.isOpen = 1; |
| 192 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -127,19 +127,19 @@ | |
| 127 | fossil_free(zHost); |
| 128 | }else{ |
| 129 | blob_append_escaped_arg(&zCmd, pUrlData->name); |
| 130 | } |
| 131 | if( !is_safe_fossil_command(pUrlData->fossil) ){ |
| 132 | fossil_fatal("the ssh:// URL is asking to run an unsafe command [%s] on " |
| 133 | "the server.", pUrlData->fossil); |
| 134 | } |
| 135 | blob_append_escaped_arg(&zCmd, pUrlData->fossil); |
| 136 | blob_append(&zCmd, " test-http", 10); |
| 137 | if( pUrlData->path && pUrlData->path[0] ){ |
| 138 | blob_append_escaped_arg(&zCmd, pUrlData->path); |
| 139 | }else{ |
| 140 | fossil_fatal("ssh:// URI does not specify a path to the repository"); |
| 141 | } |
| 142 | if( g.fSshTrace ){ |
| 143 | fossil_print("%s\n", blob_str(&zCmd)); /* Show the whole SSH command */ |
| 144 | } |
| 145 | popen2(blob_str(&zCmd), &sshIn, &sshOut, &sshPid, 0); |
| @@ -181,11 +181,11 @@ | |
| 181 | g.zRepositoryName, iRandId); |
| 182 | transport.zInFile = mprintf("%s-%llu-in.http", |
| 183 | g.zRepositoryName, iRandId); |
| 184 | transport.pFile = fossil_fopen(transport.zOutFile, "wb"); |
| 185 | if( transport.pFile==0 ){ |
| 186 | fossil_fatal("cannot output temporary file: %s", transport.zOutFile); |
| 187 | } |
| 188 | transport.isOpen = 1; |
| 189 | }else{ |
| 190 | rc = socket_open(pUrlData); |
| 191 | if( rc==0 ) transport.isOpen = 1; |
| 192 |
+1
-1
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -636,11 +636,11 @@ | ||
| 636 | 636 | if( gg.nData ){ |
| 637 | 637 | int got; |
| 638 | 638 | gg.aData = fossil_malloc( gg.nData+1 ); |
| 639 | 639 | got = fread(gg.aData, 1, gg.nData, pIn); |
| 640 | 640 | if( got!=gg.nData ){ |
| 641 | - fossil_panic("short read: got %d of %d bytes", got, gg.nData); | |
| 641 | + fossil_fatal("short read: got %d of %d bytes", got, gg.nData); | |
| 642 | 642 | } |
| 643 | 643 | gg.aData[got] = '\0'; |
| 644 | 644 | if( gg.zComment==0 && |
| 645 | 645 | (gg.xFinish==finish_commit || gg.xFinish==finish_tag) ){ |
| 646 | 646 | /* Strip trailing newline, it's appended to the comment. */ |
| 647 | 647 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -636,11 +636,11 @@ | |
| 636 | if( gg.nData ){ |
| 637 | int got; |
| 638 | gg.aData = fossil_malloc( gg.nData+1 ); |
| 639 | got = fread(gg.aData, 1, gg.nData, pIn); |
| 640 | if( got!=gg.nData ){ |
| 641 | fossil_panic("short read: got %d of %d bytes", got, gg.nData); |
| 642 | } |
| 643 | gg.aData[got] = '\0'; |
| 644 | if( gg.zComment==0 && |
| 645 | (gg.xFinish==finish_commit || gg.xFinish==finish_tag) ){ |
| 646 | /* Strip trailing newline, it's appended to the comment. */ |
| 647 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -636,11 +636,11 @@ | |
| 636 | if( gg.nData ){ |
| 637 | int got; |
| 638 | gg.aData = fossil_malloc( gg.nData+1 ); |
| 639 | got = fread(gg.aData, 1, gg.nData, pIn); |
| 640 | if( got!=gg.nData ){ |
| 641 | fossil_fatal("short read: got %d of %d bytes", got, gg.nData); |
| 642 | } |
| 643 | gg.aData[got] = '\0'; |
| 644 | if( gg.zComment==0 && |
| 645 | (gg.xFinish==finish_commit || gg.xFinish==finish_tag) ){ |
| 646 | /* Strip trailing newline, it's appended to the comment. */ |
| 647 |
+1
-1
| --- src/json_status.c | ||
| +++ src/json_status.c | ||
| @@ -167,11 +167,11 @@ | ||
| 167 | 167 | blob_append(report, zPrefix, nPrefix); |
| 168 | 168 | blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0)); |
| 169 | 169 | } |
| 170 | 170 | db_finalize(&q); |
| 171 | 171 | if( nErr ){ |
| 172 | - fossil_panic("aborting due to prior errors"); | |
| 172 | + fossil_fatal("aborting due to prior errors"); | |
| 173 | 173 | } |
| 174 | 174 | #endif |
| 175 | 175 | return cson_object_value( oPay ); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 |
| --- src/json_status.c | |
| +++ src/json_status.c | |
| @@ -167,11 +167,11 @@ | |
| 167 | blob_append(report, zPrefix, nPrefix); |
| 168 | blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0)); |
| 169 | } |
| 170 | db_finalize(&q); |
| 171 | if( nErr ){ |
| 172 | fossil_panic("aborting due to prior errors"); |
| 173 | } |
| 174 | #endif |
| 175 | return cson_object_value( oPay ); |
| 176 | } |
| 177 | |
| 178 |
| --- src/json_status.c | |
| +++ src/json_status.c | |
| @@ -167,11 +167,11 @@ | |
| 167 | blob_append(report, zPrefix, nPrefix); |
| 168 | blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0)); |
| 169 | } |
| 170 | db_finalize(&q); |
| 171 | if( nErr ){ |
| 172 | fossil_fatal("aborting due to prior errors"); |
| 173 | } |
| 174 | #endif |
| 175 | return cson_object_value( oPay ); |
| 176 | } |
| 177 | |
| 178 |
+2
-2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -1468,15 +1468,15 @@ | ||
| 1468 | 1468 | } |
| 1469 | 1469 | g.fJail = 1; |
| 1470 | 1470 | zRepo = "/"; |
| 1471 | 1471 | }else{ |
| 1472 | 1472 | for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){} |
| 1473 | - if( zDir[i]!='/' ) fossil_panic("bad repository name: %s", zRepo); | |
| 1473 | + if( zDir[i]!='/' ) fossil_fatal("bad repository name: %s", zRepo); | |
| 1474 | 1474 | if( i>0 ){ |
| 1475 | 1475 | zDir[i] = 0; |
| 1476 | 1476 | if( file_chdir(zDir, 1) ){ |
| 1477 | - fossil_panic("unable to chroot into %s", zDir); | |
| 1477 | + fossil_fatal("unable to chroot into %s", zDir); | |
| 1478 | 1478 | } |
| 1479 | 1479 | zDir[i] = '/'; |
| 1480 | 1480 | } |
| 1481 | 1481 | zRepo = &zDir[i]; |
| 1482 | 1482 | } |
| 1483 | 1483 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1468,15 +1468,15 @@ | |
| 1468 | } |
| 1469 | g.fJail = 1; |
| 1470 | zRepo = "/"; |
| 1471 | }else{ |
| 1472 | for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){} |
| 1473 | if( zDir[i]!='/' ) fossil_panic("bad repository name: %s", zRepo); |
| 1474 | if( i>0 ){ |
| 1475 | zDir[i] = 0; |
| 1476 | if( file_chdir(zDir, 1) ){ |
| 1477 | fossil_panic("unable to chroot into %s", zDir); |
| 1478 | } |
| 1479 | zDir[i] = '/'; |
| 1480 | } |
| 1481 | zRepo = &zDir[i]; |
| 1482 | } |
| 1483 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -1468,15 +1468,15 @@ | |
| 1468 | } |
| 1469 | g.fJail = 1; |
| 1470 | zRepo = "/"; |
| 1471 | }else{ |
| 1472 | for(i=strlen(zDir)-1; i>0 && zDir[i]!='/'; i--){} |
| 1473 | if( zDir[i]!='/' ) fossil_fatal("bad repository name: %s", zRepo); |
| 1474 | if( i>0 ){ |
| 1475 | zDir[i] = 0; |
| 1476 | if( file_chdir(zDir, 1) ){ |
| 1477 | fossil_fatal("unable to chroot into %s", zDir); |
| 1478 | } |
| 1479 | zDir[i] = '/'; |
| 1480 | } |
| 1481 | zRepo = &zDir[i]; |
| 1482 | } |
| 1483 |
+11
-6
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -1132,23 +1132,28 @@ | ||
| 1132 | 1132 | return rc; |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | 1135 | /* |
| 1136 | 1136 | ** Print an error message, rollback all databases, and quit. These |
| 1137 | -** routines never return. | |
| 1137 | +** routines never return and produce a non-zero process exit status. | |
| 1138 | 1138 | ** |
| 1139 | -** The only different between fossil_fatal() and fossil_panic() is that | |
| 1139 | +** The main difference between fossil_fatal() and fossil_panic() is that | |
| 1140 | 1140 | ** fossil_panic() makes an entry in the error log whereas fossil_fatal() |
| 1141 | -** does not. If there is not error log, then both routines work the | |
| 1142 | -** same. Hence, the routines are interchangable for commands and only | |
| 1143 | -** make a difference with processing web pages. | |
| 1141 | +** does not. On POSIX platforms, if there is not error log, then both | |
| 1142 | +** routines work similarly with respect to user-visible effects. Hence, | |
| 1143 | +** the routines are interchangable for commands and only act differently | |
| 1144 | +** when processing web pages. On the Windows platform, fossil_panic() | |
| 1145 | +** also displays a pop-up stating that an error has occured and allowing | |
| 1146 | +** just-in-time debugging to commence. On all platforms, fossil_panic() | |
| 1147 | +** ends execution with a SIGABRT signal, bypassing atexit processing. | |
| 1144 | 1148 | ** |
| 1145 | 1149 | ** Use fossil_fatal() for malformed inputs that should be reported back |
| 1146 | 1150 | ** to the user, but which do not represent a configuration problem or bug. |
| 1147 | 1151 | ** |
| 1148 | 1152 | ** Use fossil_panic() for any kind of error that should be brought to the |
| 1149 | -** attention of the system administrator. | |
| 1153 | +** attention of the system administrator or Fossil developers. It is to | |
| 1154 | +** be avoided for ordinary errors of usage, data entry, or I/O errors. | |
| 1150 | 1155 | */ |
| 1151 | 1156 | NORETURN void fossil_panic(const char *zFormat, ...){ |
| 1152 | 1157 | va_list ap; |
| 1153 | 1158 | int rc = 1; |
| 1154 | 1159 | char z[1000]; |
| 1155 | 1160 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -1132,23 +1132,28 @@ | |
| 1132 | return rc; |
| 1133 | } |
| 1134 | |
| 1135 | /* |
| 1136 | ** Print an error message, rollback all databases, and quit. These |
| 1137 | ** routines never return. |
| 1138 | ** |
| 1139 | ** The only different between fossil_fatal() and fossil_panic() is that |
| 1140 | ** fossil_panic() makes an entry in the error log whereas fossil_fatal() |
| 1141 | ** does not. If there is not error log, then both routines work the |
| 1142 | ** same. Hence, the routines are interchangable for commands and only |
| 1143 | ** make a difference with processing web pages. |
| 1144 | ** |
| 1145 | ** Use fossil_fatal() for malformed inputs that should be reported back |
| 1146 | ** to the user, but which do not represent a configuration problem or bug. |
| 1147 | ** |
| 1148 | ** Use fossil_panic() for any kind of error that should be brought to the |
| 1149 | ** attention of the system administrator. |
| 1150 | */ |
| 1151 | NORETURN void fossil_panic(const char *zFormat, ...){ |
| 1152 | va_list ap; |
| 1153 | int rc = 1; |
| 1154 | char z[1000]; |
| 1155 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -1132,23 +1132,28 @@ | |
| 1132 | return rc; |
| 1133 | } |
| 1134 | |
| 1135 | /* |
| 1136 | ** Print an error message, rollback all databases, and quit. These |
| 1137 | ** routines never return and produce a non-zero process exit status. |
| 1138 | ** |
| 1139 | ** The main difference between fossil_fatal() and fossil_panic() is that |
| 1140 | ** fossil_panic() makes an entry in the error log whereas fossil_fatal() |
| 1141 | ** does not. On POSIX platforms, if there is not error log, then both |
| 1142 | ** routines work similarly with respect to user-visible effects. Hence, |
| 1143 | ** the routines are interchangable for commands and only act differently |
| 1144 | ** when processing web pages. On the Windows platform, fossil_panic() |
| 1145 | ** also displays a pop-up stating that an error has occured and allowing |
| 1146 | ** just-in-time debugging to commence. On all platforms, fossil_panic() |
| 1147 | ** ends execution with a SIGABRT signal, bypassing atexit processing. |
| 1148 | ** |
| 1149 | ** Use fossil_fatal() for malformed inputs that should be reported back |
| 1150 | ** to the user, but which do not represent a configuration problem or bug. |
| 1151 | ** |
| 1152 | ** Use fossil_panic() for any kind of error that should be brought to the |
| 1153 | ** attention of the system administrator or Fossil developers. It is to |
| 1154 | ** be avoided for ordinary errors of usage, data entry, or I/O errors. |
| 1155 | */ |
| 1156 | NORETURN void fossil_panic(const char *zFormat, ...){ |
| 1157 | va_list ap; |
| 1158 | int rc = 1; |
| 1159 | char z[1000]; |
| 1160 |
+1
-1
| --- src/sqlcmd.c | ||
| +++ src/sqlcmd.c | ||
| @@ -306,11 +306,11 @@ | ||
| 306 | 306 | *pnKey = (int)strlen(zKey); |
| 307 | 307 | }else{ |
| 308 | 308 | *pnKey = -1; |
| 309 | 309 | } |
| 310 | 310 | }else{ |
| 311 | - fossil_panic("failed to allocate %u bytes for key", nByte); | |
| 311 | + fossil_fatal("failed to allocate %u bytes for key", nByte); | |
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | #endif |
| 315 | 315 | |
| 316 | 316 | /* |
| 317 | 317 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -306,11 +306,11 @@ | |
| 306 | *pnKey = (int)strlen(zKey); |
| 307 | }else{ |
| 308 | *pnKey = -1; |
| 309 | } |
| 310 | }else{ |
| 311 | fossil_panic("failed to allocate %u bytes for key", nByte); |
| 312 | } |
| 313 | } |
| 314 | #endif |
| 315 | |
| 316 | /* |
| 317 |
| --- src/sqlcmd.c | |
| +++ src/sqlcmd.c | |
| @@ -306,11 +306,11 @@ | |
| 306 | *pnKey = (int)strlen(zKey); |
| 307 | }else{ |
| 308 | *pnKey = -1; |
| 309 | } |
| 310 | }else{ |
| 311 | fossil_fatal("failed to allocate %u bytes for key", nByte); |
| 312 | } |
| 313 | } |
| 314 | #endif |
| 315 | |
| 316 | /* |
| 317 |
+1
-1
| --- src/undo.c | ||
| +++ src/undo.c | ||
| @@ -269,11 +269,11 @@ | ||
| 269 | 269 | ** tree. |
| 270 | 270 | */ |
| 271 | 271 | void undo_save(const char *zPathname){ |
| 272 | 272 | if( undoDisable ) return; |
| 273 | 273 | if( undo_maybe_save(zPathname, -1)!=UNDO_SAVED_OK ){ |
| 274 | - fossil_panic("failed to save undo information for path: %s", | |
| 274 | + fossil_fatal("failed to save undo information for path: %s", | |
| 275 | 275 | zPathname); |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /* |
| 280 | 280 |
| --- src/undo.c | |
| +++ src/undo.c | |
| @@ -269,11 +269,11 @@ | |
| 269 | ** tree. |
| 270 | */ |
| 271 | void undo_save(const char *zPathname){ |
| 272 | if( undoDisable ) return; |
| 273 | if( undo_maybe_save(zPathname, -1)!=UNDO_SAVED_OK ){ |
| 274 | fossil_panic("failed to save undo information for path: %s", |
| 275 | zPathname); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | /* |
| 280 |
| --- src/undo.c | |
| +++ src/undo.c | |
| @@ -269,11 +269,11 @@ | |
| 269 | ** tree. |
| 270 | */ |
| 271 | void undo_save(const char *zPathname){ |
| 272 | if( undoDisable ) return; |
| 273 | if( undo_maybe_save(zPathname, -1)!=UNDO_SAVED_OK ){ |
| 274 | fossil_fatal("failed to save undo information for path: %s", |
| 275 | zPathname); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | /* |
| 280 |
+7
-7
| --- src/util.c | ||
| +++ src/util.c | ||
| @@ -56,25 +56,25 @@ | ||
| 56 | 56 | /* |
| 57 | 57 | ** Malloc and free routines that cannot fail |
| 58 | 58 | */ |
| 59 | 59 | void *fossil_malloc(size_t n){ |
| 60 | 60 | void *p = malloc(n==0 ? 1 : n); |
| 61 | - if( p==0 ) fossil_panic("out of memory"); | |
| 61 | + if( p==0 ) fossil_fatal("out of memory"); | |
| 62 | 62 | return p; |
| 63 | 63 | } |
| 64 | 64 | void *fossil_malloc_zero(size_t n){ |
| 65 | 65 | void *p = malloc(n==0 ? 1 : n); |
| 66 | - if( p==0 ) fossil_panic("out of memory"); | |
| 66 | + if( p==0 ) fossil_fatal("out of memory"); | |
| 67 | 67 | memset(p, 0, n); |
| 68 | 68 | return p; |
| 69 | 69 | } |
| 70 | 70 | void fossil_free(void *p){ |
| 71 | 71 | free(p); |
| 72 | 72 | } |
| 73 | 73 | void *fossil_realloc(void *p, size_t n){ |
| 74 | 74 | p = realloc(p, n); |
| 75 | - if( p==0 ) fossil_panic("out of memory"); | |
| 75 | + if( p==0 ) fossil_fatal("out of memory"); | |
| 76 | 76 | return p; |
| 77 | 77 | } |
| 78 | 78 | void fossil_secure_zero(void *p, size_t n){ |
| 79 | 79 | volatile unsigned char *vp = (volatile unsigned char *)p; |
| 80 | 80 | size_t i; |
| @@ -105,22 +105,22 @@ | ||
| 105 | 105 | assert( pageSize>0 ); |
| 106 | 106 | assert( pageSize%2==0 ); |
| 107 | 107 | #if defined(_WIN32) |
| 108 | 108 | p = VirtualAlloc(NULL, pageSize, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE); |
| 109 | 109 | if( p==NULL ){ |
| 110 | - fossil_panic("VirtualAlloc failed: %lu\n", GetLastError()); | |
| 110 | + fossil_fatal("VirtualAlloc failed: %lu\n", GetLastError()); | |
| 111 | 111 | } |
| 112 | 112 | if( !VirtualLock(p, pageSize) ){ |
| 113 | - fossil_panic("VirtualLock failed: %lu\n", GetLastError()); | |
| 113 | + fossil_fatal("VirtualLock failed: %lu\n", GetLastError()); | |
| 114 | 114 | } |
| 115 | 115 | #elif defined(USE_MMAN_H) |
| 116 | 116 | p = mmap(0, pageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); |
| 117 | 117 | if( p==MAP_FAILED ){ |
| 118 | - fossil_panic("mmap failed: %d\n", errno); | |
| 118 | + fossil_fatal("mmap failed: %d\n", errno); | |
| 119 | 119 | } |
| 120 | 120 | if( mlock(p, pageSize) ){ |
| 121 | - fossil_panic("mlock failed: %d\n", errno); | |
| 121 | + fossil_fatal("mlock failed: %d\n", errno); | |
| 122 | 122 | } |
| 123 | 123 | #else |
| 124 | 124 | p = fossil_malloc(pageSize); |
| 125 | 125 | #endif |
| 126 | 126 | fossil_secure_zero(p, pageSize); |
| 127 | 127 |
| --- src/util.c | |
| +++ src/util.c | |
| @@ -56,25 +56,25 @@ | |
| 56 | /* |
| 57 | ** Malloc and free routines that cannot fail |
| 58 | */ |
| 59 | void *fossil_malloc(size_t n){ |
| 60 | void *p = malloc(n==0 ? 1 : n); |
| 61 | if( p==0 ) fossil_panic("out of memory"); |
| 62 | return p; |
| 63 | } |
| 64 | void *fossil_malloc_zero(size_t n){ |
| 65 | void *p = malloc(n==0 ? 1 : n); |
| 66 | if( p==0 ) fossil_panic("out of memory"); |
| 67 | memset(p, 0, n); |
| 68 | return p; |
| 69 | } |
| 70 | void fossil_free(void *p){ |
| 71 | free(p); |
| 72 | } |
| 73 | void *fossil_realloc(void *p, size_t n){ |
| 74 | p = realloc(p, n); |
| 75 | if( p==0 ) fossil_panic("out of memory"); |
| 76 | return p; |
| 77 | } |
| 78 | void fossil_secure_zero(void *p, size_t n){ |
| 79 | volatile unsigned char *vp = (volatile unsigned char *)p; |
| 80 | size_t i; |
| @@ -105,22 +105,22 @@ | |
| 105 | assert( pageSize>0 ); |
| 106 | assert( pageSize%2==0 ); |
| 107 | #if defined(_WIN32) |
| 108 | p = VirtualAlloc(NULL, pageSize, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE); |
| 109 | if( p==NULL ){ |
| 110 | fossil_panic("VirtualAlloc failed: %lu\n", GetLastError()); |
| 111 | } |
| 112 | if( !VirtualLock(p, pageSize) ){ |
| 113 | fossil_panic("VirtualLock failed: %lu\n", GetLastError()); |
| 114 | } |
| 115 | #elif defined(USE_MMAN_H) |
| 116 | p = mmap(0, pageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); |
| 117 | if( p==MAP_FAILED ){ |
| 118 | fossil_panic("mmap failed: %d\n", errno); |
| 119 | } |
| 120 | if( mlock(p, pageSize) ){ |
| 121 | fossil_panic("mlock failed: %d\n", errno); |
| 122 | } |
| 123 | #else |
| 124 | p = fossil_malloc(pageSize); |
| 125 | #endif |
| 126 | fossil_secure_zero(p, pageSize); |
| 127 |
| --- src/util.c | |
| +++ src/util.c | |
| @@ -56,25 +56,25 @@ | |
| 56 | /* |
| 57 | ** Malloc and free routines that cannot fail |
| 58 | */ |
| 59 | void *fossil_malloc(size_t n){ |
| 60 | void *p = malloc(n==0 ? 1 : n); |
| 61 | if( p==0 ) fossil_fatal("out of memory"); |
| 62 | return p; |
| 63 | } |
| 64 | void *fossil_malloc_zero(size_t n){ |
| 65 | void *p = malloc(n==0 ? 1 : n); |
| 66 | if( p==0 ) fossil_fatal("out of memory"); |
| 67 | memset(p, 0, n); |
| 68 | return p; |
| 69 | } |
| 70 | void fossil_free(void *p){ |
| 71 | free(p); |
| 72 | } |
| 73 | void *fossil_realloc(void *p, size_t n){ |
| 74 | p = realloc(p, n); |
| 75 | if( p==0 ) fossil_fatal("out of memory"); |
| 76 | return p; |
| 77 | } |
| 78 | void fossil_secure_zero(void *p, size_t n){ |
| 79 | volatile unsigned char *vp = (volatile unsigned char *)p; |
| 80 | size_t i; |
| @@ -105,22 +105,22 @@ | |
| 105 | assert( pageSize>0 ); |
| 106 | assert( pageSize%2==0 ); |
| 107 | #if defined(_WIN32) |
| 108 | p = VirtualAlloc(NULL, pageSize, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE); |
| 109 | if( p==NULL ){ |
| 110 | fossil_fatal("VirtualAlloc failed: %lu\n", GetLastError()); |
| 111 | } |
| 112 | if( !VirtualLock(p, pageSize) ){ |
| 113 | fossil_fatal("VirtualLock failed: %lu\n", GetLastError()); |
| 114 | } |
| 115 | #elif defined(USE_MMAN_H) |
| 116 | p = mmap(0, pageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); |
| 117 | if( p==MAP_FAILED ){ |
| 118 | fossil_fatal("mmap failed: %d\n", errno); |
| 119 | } |
| 120 | if( mlock(p, pageSize) ){ |
| 121 | fossil_fatal("mlock failed: %d\n", errno); |
| 122 | } |
| 123 | #else |
| 124 | p = fossil_malloc(pageSize); |
| 125 | #endif |
| 126 | fossil_secure_zero(p, pageSize); |
| 127 |
+1
-1
| --- src/winfile.c | ||
| +++ src/winfile.c | ||
| @@ -282,11 +282,11 @@ | ||
| 282 | 282 | void win32_getcwd(char *zBuf, int nBuf){ |
| 283 | 283 | int i; |
| 284 | 284 | char *zUtf8; |
| 285 | 285 | wchar_t *zWide = fossil_malloc( sizeof(wchar_t)*nBuf ); |
| 286 | 286 | if( GetCurrentDirectoryW(nBuf, zWide)==0 ){ |
| 287 | - fossil_panic("cannot find current working directory."); | |
| 287 | + fossil_fatal("cannot find current working directory."); | |
| 288 | 288 | } |
| 289 | 289 | zUtf8 = fossil_path_to_utf8(zWide); |
| 290 | 290 | fossil_free(zWide); |
| 291 | 291 | for(i=0; zUtf8[i]; i++) if( zUtf8[i]=='\\' ) zUtf8[i] = '/'; |
| 292 | 292 | strncpy(zBuf, zUtf8, nBuf); |
| 293 | 293 |
| --- src/winfile.c | |
| +++ src/winfile.c | |
| @@ -282,11 +282,11 @@ | |
| 282 | void win32_getcwd(char *zBuf, int nBuf){ |
| 283 | int i; |
| 284 | char *zUtf8; |
| 285 | wchar_t *zWide = fossil_malloc( sizeof(wchar_t)*nBuf ); |
| 286 | if( GetCurrentDirectoryW(nBuf, zWide)==0 ){ |
| 287 | fossil_panic("cannot find current working directory."); |
| 288 | } |
| 289 | zUtf8 = fossil_path_to_utf8(zWide); |
| 290 | fossil_free(zWide); |
| 291 | for(i=0; zUtf8[i]; i++) if( zUtf8[i]=='\\' ) zUtf8[i] = '/'; |
| 292 | strncpy(zBuf, zUtf8, nBuf); |
| 293 |
| --- src/winfile.c | |
| +++ src/winfile.c | |
| @@ -282,11 +282,11 @@ | |
| 282 | void win32_getcwd(char *zBuf, int nBuf){ |
| 283 | int i; |
| 284 | char *zUtf8; |
| 285 | wchar_t *zWide = fossil_malloc( sizeof(wchar_t)*nBuf ); |
| 286 | if( GetCurrentDirectoryW(nBuf, zWide)==0 ){ |
| 287 | fossil_fatal("cannot find current working directory."); |
| 288 | } |
| 289 | zUtf8 = fossil_path_to_utf8(zWide); |
| 290 | fossil_free(zWide); |
| 291 | for(i=0; zUtf8[i]; i++) if( zUtf8[i]=='\\' ) zUtf8[i] = '/'; |
| 292 | strncpy(zBuf, zUtf8, nBuf); |
| 293 |
+5
-4
| --- src/winhttp.c | ||
| +++ src/winhttp.c | ||
| @@ -288,11 +288,11 @@ | ||
| 288 | 288 | static NORETURN void winhttp_fatal( |
| 289 | 289 | const char *zOp, |
| 290 | 290 | const char *zService, |
| 291 | 291 | const char *zErr |
| 292 | 292 | ){ |
| 293 | - fossil_panic("unable to %s service '%s': %s", zOp, zService, zErr); | |
| 293 | + fossil_fatal("unable to %s service '%s': %s", zOp, zService, zErr); | |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /* |
| 297 | 297 | ** Make sure the server stops as soon as possible after the stopper file |
| 298 | 298 | ** is found. If there is no stopper file name, do nothing. |
| @@ -604,14 +604,15 @@ | ||
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | break; |
| 607 | 607 | } |
| 608 | 608 | if( iPort>mxPort ){ |
| 609 | + /* These exits are merely fatal because firewall settings can cause them. */ | |
| 609 | 610 | if( mnPort==mxPort ){ |
| 610 | - fossil_panic("unable to open listening socket on port %d", mnPort); | |
| 611 | + fossil_fatal("unable to open listening socket on port %d", mnPort); | |
| 611 | 612 | }else{ |
| 612 | - fossil_panic("unable to open listening socket on any" | |
| 613 | + fossil_fatal("unable to open listening socket on any" | |
| 613 | 614 | " port in the range %d..%d", mnPort, mxPort); |
| 614 | 615 | } |
| 615 | 616 | } |
| 616 | 617 | if( !GetTempPathW(MAX_PATH, zTmpPath) ){ |
| 617 | 618 | fossil_panic("unable to get path to the temporary directory."); |
| @@ -908,11 +909,11 @@ | ||
| 908 | 909 | /* Try to start the control dispatcher thread for the service. */ |
| 909 | 910 | if( !StartServiceCtrlDispatcherW(ServiceTable) ){ |
| 910 | 911 | if( GetLastError()==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ){ |
| 911 | 912 | return 1; |
| 912 | 913 | }else{ |
| 913 | - fossil_panic("error from StartServiceCtrlDispatcher()"); | |
| 914 | + fossil_fatal("error from StartServiceCtrlDispatcher()"); | |
| 914 | 915 | } |
| 915 | 916 | } |
| 916 | 917 | return 0; |
| 917 | 918 | } |
| 918 | 919 | |
| 919 | 920 |
| --- src/winhttp.c | |
| +++ src/winhttp.c | |
| @@ -288,11 +288,11 @@ | |
| 288 | static NORETURN void winhttp_fatal( |
| 289 | const char *zOp, |
| 290 | const char *zService, |
| 291 | const char *zErr |
| 292 | ){ |
| 293 | fossil_panic("unable to %s service '%s': %s", zOp, zService, zErr); |
| 294 | } |
| 295 | |
| 296 | /* |
| 297 | ** Make sure the server stops as soon as possible after the stopper file |
| 298 | ** is found. If there is no stopper file name, do nothing. |
| @@ -604,14 +604,15 @@ | |
| 604 | } |
| 605 | } |
| 606 | break; |
| 607 | } |
| 608 | if( iPort>mxPort ){ |
| 609 | if( mnPort==mxPort ){ |
| 610 | fossil_panic("unable to open listening socket on port %d", mnPort); |
| 611 | }else{ |
| 612 | fossil_panic("unable to open listening socket on any" |
| 613 | " port in the range %d..%d", mnPort, mxPort); |
| 614 | } |
| 615 | } |
| 616 | if( !GetTempPathW(MAX_PATH, zTmpPath) ){ |
| 617 | fossil_panic("unable to get path to the temporary directory."); |
| @@ -908,11 +909,11 @@ | |
| 908 | /* Try to start the control dispatcher thread for the service. */ |
| 909 | if( !StartServiceCtrlDispatcherW(ServiceTable) ){ |
| 910 | if( GetLastError()==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ){ |
| 911 | return 1; |
| 912 | }else{ |
| 913 | fossil_panic("error from StartServiceCtrlDispatcher()"); |
| 914 | } |
| 915 | } |
| 916 | return 0; |
| 917 | } |
| 918 | |
| 919 |
| --- src/winhttp.c | |
| +++ src/winhttp.c | |
| @@ -288,11 +288,11 @@ | |
| 288 | static NORETURN void winhttp_fatal( |
| 289 | const char *zOp, |
| 290 | const char *zService, |
| 291 | const char *zErr |
| 292 | ){ |
| 293 | fossil_fatal("unable to %s service '%s': %s", zOp, zService, zErr); |
| 294 | } |
| 295 | |
| 296 | /* |
| 297 | ** Make sure the server stops as soon as possible after the stopper file |
| 298 | ** is found. If there is no stopper file name, do nothing. |
| @@ -604,14 +604,15 @@ | |
| 604 | } |
| 605 | } |
| 606 | break; |
| 607 | } |
| 608 | if( iPort>mxPort ){ |
| 609 | /* These exits are merely fatal because firewall settings can cause them. */ |
| 610 | if( mnPort==mxPort ){ |
| 611 | fossil_fatal("unable to open listening socket on port %d", mnPort); |
| 612 | }else{ |
| 613 | fossil_fatal("unable to open listening socket on any" |
| 614 | " port in the range %d..%d", mnPort, mxPort); |
| 615 | } |
| 616 | } |
| 617 | if( !GetTempPathW(MAX_PATH, zTmpPath) ){ |
| 618 | fossil_panic("unable to get path to the temporary directory."); |
| @@ -908,11 +909,11 @@ | |
| 909 | /* Try to start the control dispatcher thread for the service. */ |
| 910 | if( !StartServiceCtrlDispatcherW(ServiceTable) ){ |
| 911 | if( GetLastError()==ERROR_FAILED_SERVICE_CONTROLLER_CONNECT ){ |
| 912 | return 1; |
| 913 | }else{ |
| 914 | fossil_fatal("error from StartServiceCtrlDispatcher()"); |
| 915 | } |
| 916 | } |
| 917 | return 0; |
| 918 | } |
| 919 | |
| 920 |