From: Nick Mathewson Date: Fri, 15 Sep 2017 20:40:11 +0000 (-0400) Subject: Merge branch 'scan-build-032' X-Git-Tag: tor-0.3.2.1-alpha~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=76c33f7ff46df47df0cc880595c4d943d50f019b;p=thirdparty%2Ftor.git Merge branch 'scan-build-032' --- 76c33f7ff46df47df0cc880595c4d943d50f019b diff --cc src/common/compat.c index d377c922c8,ab117f7c72..ab1fbc64fe --- a/src/common/compat.c +++ b/src/common/compat.c @@@ -2242,17 -2239,15 +2240,14 @@@ tor_disable_debugger_attach(void log_debug(LD_CONFIG, "Attemping to disable debugger attachment to Tor for " "unprivileged users."); -#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) && defined(HAVE_PRCTL) -#ifdef PR_SET_DUMPABLE +#if defined(__linux__) && defined(HAVE_SYS_PRCTL_H) \ + && defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) - attempted = 1; + #define TRIED_TO_DISABLE r = prctl(PR_SET_DUMPABLE, 0); --#endif - #if defined(__APPLE__) && defined(PT_DENY_ATTACH) - if (r < 0) { - attempted = 1; - r = ptrace(PT_DENY_ATTACH, 0, 0, 0); - } - #endif /* defined(__APPLE__) && defined(PT_DENY_ATTACH) */ + #elif defined(__APPLE__) && defined(PT_DENY_ATTACH) -#define TRIED_TO_DISABLE ++#define TRIED_TO_ATTACH + r = ptrace(PT_DENY_ATTACH, 0, 0, 0); -#endif ++#endif /* defined(__linux__) && defined(HAVE_SYS_PRCTL_H) ... || ... */ // XXX: TODO - Mac OS X has dtrace and this may be disabled. // XXX: TODO - Windows probably has something similar @@@ -2264,6 -2260,8 +2260,8 @@@ log_warn(LD_CONFIG, "Unable to disable debugger attaching: %s", strerror(errno)); } -#endif ++#endif /* defined(TRIED_TO_DISABLE) */ + #undef TRIED_TO_DISABLE return r; } diff --cc src/common/util.c index b262691d72,c8358ea705..bcb1449a18 --- a/src/common/util.c +++ b/src/common/util.c @@@ -4383,11 -4376,11 +4382,11 @@@ tor_spawn_background(const char *const "Cannot find maximum file descriptor, assuming %d", max_fd); } } -#else +#else /* !(defined(_SC_OPEN_MAX)) */ max_fd = DEFAULT_MAX_FD; -#endif +#endif /* defined(_SC_OPEN_MAX) */ - child_state = CHILD_STATE_FORK; + // child_state = CHILD_STATE_FORK; pid = fork(); if (0 == pid) { @@@ -4540,8 -4535,8 +4541,8 @@@ } *process_handle_out = process_handle; - return process_handle->status; + return status; -#endif // _WIN32 +#endif /* defined(_WIN32) */ } /** Destroy all resources allocated by the process handle in diff --cc src/test/test_hs_common.c index 2d63dff250,3cacbab0f0..22fed12f1e --- a/src/test/test_hs_common.c +++ b/src/test/test_hs_common.c @@@ -1588,7 -1512,7 +1589,7 @@@ helper_test_hsdir_sync(networkstatus_t tt_int_op(smartlist_len(desc->previous_hsdirs), OP_EQ, 6); /* 3) Initialize client time */ - now = helper_set_consensus_and_system_time(ns, client_position); - helper_set_consensus_and_system_time(ns, client_between_srv_and_tp); ++ helper_set_consensus_and_system_time(ns, client_position); cleanup_nodelist(); SMARTLIST_FOREACH(ns->routerstatus_list,