Fossil SCM

Attempt to make an error log entry following a segfault.

drh 2018-06-29 12:56 trunk
Commit c670925e00e71b774332629c5d5c8b537c2a72ae9eb5f8fdcaa65ec5a85cb625
3 files changed +5 -3 +13 -1 +1 -1
+5 -3
--- src/email.c
+++ src/email.c
@@ -415,13 +415,15 @@
415415
416416
/*
417417
** Free an email sender object
418418
*/
419419
void email_sender_free(EmailSender *p){
420
- emailerShutdown(p);
421
- fossil_free(p->zErr);
422
- fossil_free(p);
420
+ if( p ){
421
+ emailerShutdown(p);
422
+ fossil_free(p->zErr);
423
+ fossil_free(p);
424
+ }
423425
}
424426
425427
/*
426428
** Get an email setting value. Report an error if not configured.
427429
** Return 0 on success and one if there is an error.
428430
--- src/email.c
+++ src/email.c
@@ -415,13 +415,15 @@
415
416 /*
417 ** Free an email sender object
418 */
419 void email_sender_free(EmailSender *p){
420 emailerShutdown(p);
421 fossil_free(p->zErr);
422 fossil_free(p);
 
 
423 }
424
425 /*
426 ** Get an email setting value. Report an error if not configured.
427 ** Return 0 on success and one if there is an error.
428
--- src/email.c
+++ src/email.c
@@ -415,13 +415,15 @@
415
416 /*
417 ** Free an email sender object
418 */
419 void email_sender_free(EmailSender *p){
420 if( p ){
421 emailerShutdown(p);
422 fossil_free(p->zErr);
423 fossil_free(p);
424 }
425 }
426
427 /*
428 ** Get an email setting value. Report an error if not configured.
429 ** Return 0 on success and one if there is an error.
430
+13 -1
--- src/main.c
+++ src/main.c
@@ -1205,11 +1205,11 @@
12051205
**
12061206
** The noJail flag means that the chroot jail is not entered. But
12071207
** privileges are still lowered to that of the user-id and group-id
12081208
** of the repository file.
12091209
*/
1210
-static char *enter_chroot_jail(char *zRepo, int noJail){
1210
+char *enter_chroot_jail(char *zRepo, int noJail){
12111211
#if !defined(_WIN32)
12121212
if( getuid()==0 ){
12131213
int i;
12141214
struct stat sStat;
12151215
Blob dir;
@@ -1396,10 +1396,18 @@
13961396
g.zRepositoryName = g.argv[2];
13971397
}
13981398
g.httpOut = stdout;
13991399
repo_list_page();
14001400
}
1401
+
1402
+/*
1403
+** Called whenever a crash is encountered while processing a webpage.
1404
+*/
1405
+void sigsegv_handler(int x){
1406
+ fossil_errorlog("Segfault");
1407
+ exit(1);
1408
+}
14011409
14021410
/*
14031411
** Preconditions:
14041412
**
14051413
** * Environment variables are set up according to the CGI standard.
@@ -1429,10 +1437,14 @@
14291437
const char *zPathInfo = PD("PATH_INFO", "");
14301438
char *zPath = NULL;
14311439
int i;
14321440
const CmdOrPage *pCmd = 0;
14331441
const char *zBase = g.zRepositoryName;
1442
+
1443
+#if !defined(_WIN32)
1444
+ signal(SIGSEGV, sigsegv_handler);
1445
+#endif
14341446
14351447
/* Handle universal query parameters */
14361448
if( PB("utc") ){
14371449
g.fTimeFormat = 1;
14381450
}else if( PB("localtime") ){
14391451
--- src/main.c
+++ src/main.c
@@ -1205,11 +1205,11 @@
1205 **
1206 ** The noJail flag means that the chroot jail is not entered. But
1207 ** privileges are still lowered to that of the user-id and group-id
1208 ** of the repository file.
1209 */
1210 static char *enter_chroot_jail(char *zRepo, int noJail){
1211 #if !defined(_WIN32)
1212 if( getuid()==0 ){
1213 int i;
1214 struct stat sStat;
1215 Blob dir;
@@ -1396,10 +1396,18 @@
1396 g.zRepositoryName = g.argv[2];
1397 }
1398 g.httpOut = stdout;
1399 repo_list_page();
1400 }
 
 
 
 
 
 
 
 
1401
1402 /*
1403 ** Preconditions:
1404 **
1405 ** * Environment variables are set up according to the CGI standard.
@@ -1429,10 +1437,14 @@
1429 const char *zPathInfo = PD("PATH_INFO", "");
1430 char *zPath = NULL;
1431 int i;
1432 const CmdOrPage *pCmd = 0;
1433 const char *zBase = g.zRepositoryName;
 
 
 
 
1434
1435 /* Handle universal query parameters */
1436 if( PB("utc") ){
1437 g.fTimeFormat = 1;
1438 }else if( PB("localtime") ){
1439
--- src/main.c
+++ src/main.c
@@ -1205,11 +1205,11 @@
1205 **
1206 ** The noJail flag means that the chroot jail is not entered. But
1207 ** privileges are still lowered to that of the user-id and group-id
1208 ** of the repository file.
1209 */
1210 char *enter_chroot_jail(char *zRepo, int noJail){
1211 #if !defined(_WIN32)
1212 if( getuid()==0 ){
1213 int i;
1214 struct stat sStat;
1215 Blob dir;
@@ -1396,10 +1396,18 @@
1396 g.zRepositoryName = g.argv[2];
1397 }
1398 g.httpOut = stdout;
1399 repo_list_page();
1400 }
1401
1402 /*
1403 ** Called whenever a crash is encountered while processing a webpage.
1404 */
1405 void sigsegv_handler(int x){
1406 fossil_errorlog("Segfault");
1407 exit(1);
1408 }
1409
1410 /*
1411 ** Preconditions:
1412 **
1413 ** * Environment variables are set up according to the CGI standard.
@@ -1429,10 +1437,14 @@
1437 const char *zPathInfo = PD("PATH_INFO", "");
1438 char *zPath = NULL;
1439 int i;
1440 const CmdOrPage *pCmd = 0;
1441 const char *zBase = g.zRepositoryName;
1442
1443 #if !defined(_WIN32)
1444 signal(SIGSEGV, sigsegv_handler);
1445 #endif
1446
1447 /* Handle universal query parameters */
1448 if( PB("utc") ){
1449 g.fTimeFormat = 1;
1450 }else if( PB("localtime") ){
1451
+1 -1
--- src/printf.c
+++ src/printf.c
@@ -981,11 +981,11 @@
981981
982982
/*
983983
** Write a message to the error log, if the error log filename is
984984
** defined.
985985
*/
986
-static void fossil_errorlog(const char *zFormat, ...){
986
+void fossil_errorlog(const char *zFormat, ...){
987987
struct tm *pNow;
988988
time_t now;
989989
FILE *out;
990990
const char *z;
991991
int i;
992992
--- src/printf.c
+++ src/printf.c
@@ -981,11 +981,11 @@
981
982 /*
983 ** Write a message to the error log, if the error log filename is
984 ** defined.
985 */
986 static void fossil_errorlog(const char *zFormat, ...){
987 struct tm *pNow;
988 time_t now;
989 FILE *out;
990 const char *z;
991 int i;
992
--- src/printf.c
+++ src/printf.c
@@ -981,11 +981,11 @@
981
982 /*
983 ** Write a message to the error log, if the error log filename is
984 ** defined.
985 */
986 void fossil_errorlog(const char *zFormat, ...){
987 struct tm *pNow;
988 time_t now;
989 FILE *out;
990 const char *z;
991 int i;
992

Keyboard Shortcuts

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