X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=errlog.c;h=05b7dd8e4fc70f8807c460ae06923325705116c9;hp=96da0daf7d32f18f4cd229e09facbf9a617e6e76;hb=e6cd35ae9b23649990e7e05d8cc12bbb471cd5d5;hpb=43980e5c0dbe1b2090fa04f69c3989960f1d8975 diff --git a/errlog.c b/errlog.c index 96da0daf..05b7dd8e 100644 --- a/errlog.c +++ b/errlog.c @@ -1,4 +1,4 @@ -const char errlog_rcs[] = "$Id: errlog.c,v 1.119 2014/06/02 06:19:05 fabiankeil Exp $"; +const char errlog_rcs[] = "$Id: errlog.c,v 1.126 2016/02/26 12:29:38 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -245,6 +245,17 @@ void init_log_module(void) *********************************************************************/ void set_debug_level(int debug_level) { +#ifdef FUZZ + if (LOG_LEVEL_STFU == debug_level) + { + debug = LOG_LEVEL_STFU; + } + if (LOG_LEVEL_STFU == debug) + { + return; + } +#endif + debug = debug_level | LOG_LEVEL_MINIMUM; } @@ -409,7 +420,7 @@ void init_error_log(const char *prog_name, const char *logfname) *********************************************************************/ static long get_thread_id(void) { - long this_thread = 1; /* was: pthread_t this_thread;*/ + long this_thread; #ifdef __OS2__ PTIB ptib; @@ -421,12 +432,11 @@ static long get_thread_id(void) this_thread = (long)pthread_self(); #ifdef __MACH__ /* - * Mac OSX (and perhaps other Mach instances) doesn't have a debuggable - * value at the first 4 bytes of pthread_self()'s return value, a pthread_t. - * pthread_t is supposed to be opaque... but it's fairly random, though, so - * we make it mostly presentable. + * Mac OSX (and perhaps other Mach instances) doesn't have a unique + * value at the lowest order 4 bytes of pthread_self()'s return value, a pthread_t, + * so trim the three lowest-order bytes from the value (16^3). */ - this_thread = abs(this_thread % 1000); + this_thread = this_thread / 4096; #endif /* def __MACH__ */ #elif defined(_WIN32) this_thread = GetCurrentThreadId(); @@ -434,6 +444,9 @@ static long get_thread_id(void) ulrc = DosGetInfoBlocks(&ptib, NULL); if (ulrc == 0) this_thread = ptib -> tib_ptib2 -> tib2_ultid; +#else + /* Forking instead of threading. */ + this_thread = 1; #endif /* def FEATURE_PTHREAD */ return this_thread; @@ -698,6 +711,12 @@ void log_error(int loglevel, const char *fmt, ...) #endif ) { +#ifdef FUZZ + if (debug == LOG_LEVEL_STFU) + { + return; + } +#endif if (loglevel == LOG_LEVEL_FATAL) { fatal_error("Fatal error. You're not supposed to" @@ -714,15 +733,7 @@ void log_error(int loglevel, const char *fmt, ...) if (NULL == outbuf_save) { - outbuf_save = (char*)zalloc(log_buffer_size + 1); /* +1 for paranoia */ - if (NULL == outbuf_save) - { - snprintf(tempbuf, sizeof(tempbuf), - "%s %08lx Fatal error: Out of memory in log_error().", - timestamp, thread_id); - fatal_error(tempbuf); /* Exit */ - return; - } + outbuf_save = zalloc_or_die(log_buffer_size + 1); /* +1 for paranoia */ } outbuf = outbuf_save; @@ -998,9 +1009,6 @@ const char *jb_err_to_string(int jb_error) return "File has been modified outside of the CGI actions editor."; case JB_ERR_COMPRESS: return "(De)compression failure"; - default: - assert(0); - return "Unknown error"; } assert(0); return "Internal error";