diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-09-15 16:40:11 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-09-15 16:40:11 -0400 |
commit | 76c33f7ff46df47df0cc880595c4d943d50f019b (patch) | |
tree | 11448ec9afd6990160ce6212c020d3c2630448d6 /src/common/compat.c | |
parent | c1deabd3b0c9e2701696afc80ac8392f0efda2c7 (diff) | |
parent | a28e239b171c1a69fd32b6583bca0559f7116445 (diff) | |
download | tor-76c33f7ff46df47df0cc880595c4d943d50f019b.tar.gz tor-76c33f7ff46df47df0cc880595c4d943d50f019b.zip |
Merge branch 'scan-build-032'
Diffstat (limited to 'src/common/compat.c')
-rw-r--r-- | src/common/compat.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index d377c922c8..ab1fbc64fe 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -2236,34 +2236,32 @@ switch_id(const char *user, const unsigned flags) int tor_disable_debugger_attach(void) { - int r, attempted; - r = -1; - attempted = 0; + int r = -1; 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) && 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_ATTACH + r = ptrace(PT_DENY_ATTACH, 0, 0, 0); +#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 - if (r == 0 && attempted) { +#ifdef TRIED_TO_DISABLE + if (r == 0) { log_debug(LD_CONFIG,"Debugger attachment disabled for " "unprivileged users."); return 1; - } else if (attempted) { + } else { log_warn(LD_CONFIG, "Unable to disable debugger attaching: %s", strerror(errno)); } +#endif /* defined(TRIED_TO_DISABLE) */ +#undef TRIED_TO_DISABLE return r; } @@ -2582,6 +2580,7 @@ tor_inet_pton(int af, const char *src, void *dst) int gapPos = -1, i, setWords=0; const char *dot = strchr(src, '.'); const char *eow; /* end of words. */ + memset(words, 0xf8, sizeof(words)); if (dot == src) return 0; else if (!dot) |