diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-06-16 09:50:52 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-06-16 09:50:52 -0400 |
commit | d1ab295d7b2c4c8bd3da5e1774bc352f8cfe72ab (patch) | |
tree | 921913749ae3025817b8f70b1819004231cbffa1 | |
parent | f986e268505118265fa8fba14a7a5dc1331110c3 (diff) | |
download | tor-d1ab295d7b2c4c8bd3da5e1774bc352f8cfe72ab.tar.gz tor-d1ab295d7b2c4c8bd3da5e1774bc352f8cfe72ab.zip |
add LCOV_EXCL for unreachable exit() blocks in src/common
-rw-r--r-- | src/common/aes.c | 2 | ||||
-rw-r--r-- | src/common/compat.c | 4 | ||||
-rw-r--r-- | src/common/compat_libevent.c | 2 | ||||
-rw-r--r-- | src/common/util.c | 16 |
4 files changed, 23 insertions, 1 deletions
diff --git a/src/common/aes.c b/src/common/aes.c index db250c878e..2b8a68c4a2 100644 --- a/src/common/aes.c +++ b/src/common/aes.c @@ -238,9 +238,11 @@ evaluate_ctr_for_aes(void) if (fast_memneq(output, encrypt_zero, 16)) { /* Counter mode is buggy */ + /* LCOV_EXCL_START */ log_err(LD_CRYPTO, "This OpenSSL has a buggy version of counter mode; " "quitting tor."); exit(1); + /* LCOV_EXCL_STOP */ } return 0; } diff --git a/src/common/compat.c b/src/common/compat.c index 023325bf57..370881b07e 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -2876,18 +2876,22 @@ tor_gettimeofday(struct timeval *timeval) /* number of 100-nsec units since Jan 1, 1601 */ GetSystemTimeAsFileTime(&ft.ft_ft); if (ft.ft_64 < EPOCH_BIAS) { + /* LCOV_EXCL_START */ log_err(LD_GENERAL,"System time is before 1970; failing."); exit(1); + /* LCOV_EXCL_STOP */ } ft.ft_64 -= EPOCH_BIAS; timeval->tv_sec = (unsigned) (ft.ft_64 / UNITS_PER_SEC); timeval->tv_usec = (unsigned) ((ft.ft_64 / UNITS_PER_USEC) % USEC_PER_SEC); #elif defined(HAVE_GETTIMEOFDAY) if (gettimeofday(timeval, NULL)) { + /* LCOV_EXCL_START */ log_err(LD_GENERAL,"gettimeofday failed."); /* If gettimeofday dies, we have either given a bad timezone (we didn't), or segfaulted.*/ exit(1); + /* LCOV_EXCL_STOP */ } #elif defined(HAVE_FTIME) struct timeb tb; diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c index 96fcec54d4..4469f15ac7 100644 --- a/src/common/compat_libevent.c +++ b/src/common/compat_libevent.c @@ -228,8 +228,10 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg) #endif if (!the_event_base) { + /* LCOV_EXCL_START */ log_err(LD_GENERAL, "Unable to initialize Libevent: cannot continue."); exit(1); + /* LCOV_EXCL_STOP */ } /* Making this a NOTICE for now so we can link bugs to a libevent versions diff --git a/src/common/util.c b/src/common/util.c index b773aa79d0..2a3aec525a 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -155,11 +155,13 @@ tor_malloc_(size_t size DMALLOC_PARAMS) #endif if (PREDICT_UNLIKELY(result == NULL)) { + /* LCOV_EXCL_START */ log_err(LD_MM,"Out of memory on malloc(). Dying."); /* If these functions die within a worker process, they won't call * spawn_exit, but that's ok, since the parent will run out of memory soon * anyway. */ exit(1); + /* LCOV_EXCL_STOP */ } return result; } @@ -243,8 +245,10 @@ tor_realloc_(void *ptr, size_t size DMALLOC_PARAMS) #endif if (PREDICT_UNLIKELY(result == NULL)) { + /* LCOV_EXCL_START */ log_err(LD_MM,"Out of memory on realloc(). Dying."); exit(1); + /* LCOV_EXCL_STOP */ } return result; } @@ -279,8 +283,10 @@ tor_strdup_(const char *s DMALLOC_PARAMS) dup = strdup(s); #endif if (PREDICT_UNLIKELY(dup == NULL)) { + /* LCOV_EXCL_START */ log_err(LD_MM,"Out of memory on strdup(). Dying."); exit(1); + /* LCOV_EXCL_STOP */ } return dup; } @@ -3470,13 +3476,17 @@ start_daemon(void) start_daemon_called = 1; if (pipe(daemon_filedes)) { + /* LCOV_EXCL_START */ log_err(LD_GENERAL,"pipe failed; exiting. Error was %s", strerror(errno)); exit(1); + /* LCOV_EXCL_STOP */ } pid = fork(); if (pid < 0) { + /* LCOV_EXCL_START */ log_err(LD_GENERAL,"fork failed. Exiting."); exit(1); + /* LCOV_EXCL_STOP */ } if (pid) { /* Parent */ int ok; @@ -3538,8 +3548,10 @@ finish_daemon(const char *desired_cwd) nullfd = tor_open_cloexec("/dev/null", O_RDWR, 0); if (nullfd < 0) { + /* LCOV_EXCL_START */ log_err(LD_GENERAL,"/dev/null can't be opened. Exiting."); exit(1); + /* LCOV_EXCL_STOP */ } /* close fds linking to invoking terminal, but * close usual incoming fds, but redirect them somewhere @@ -3548,8 +3560,10 @@ finish_daemon(const char *desired_cwd) if (dup2(nullfd,0) < 0 || dup2(nullfd,1) < 0 || dup2(nullfd,2) < 0) { + /* LCOV_EXCL_START */ log_err(LD_GENERAL,"dup2 failed. Exiting."); exit(1); + /* LCOV_EXCL_STOP */ } if (nullfd > 2) close(nullfd); @@ -4324,7 +4338,7 @@ tor_spawn_background(const char *const filename, const char **argv, _exit(255); /* Never reached, but avoids compiler warning */ - return status; + return status; // LCOV_EXCL_LINE } /* In parent */ |