diff options
author | rl1987 <rl1987@sdf.lonestar.org> | 2019-03-22 13:44:02 +0200 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-03-29 14:26:03 -0400 |
commit | 9c132a5f9e87a2cd0f59bd8d21226ba2256f7bce (patch) | |
tree | 666535991f7882f95ce70e871e8886963d7bf631 | |
parent | bf953fe602a973259723dacb4389d3c4bee7e0a4 (diff) | |
download | tor-9c132a5f9e87a2cd0f59bd8d21226ba2256f7bce.tar.gz tor-9c132a5f9e87a2cd0f59bd8d21226ba2256f7bce.zip |
Refrain from using static buffer for assert failure message; call tor_asprintf() instead
-rw-r--r-- | src/lib/log/util_bug.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/log/util_bug.c b/src/lib/log/util_bug.c index 1ce48c0ebb..e5d5a2958c 100644 --- a/src/lib/log/util_bug.c +++ b/src/lib/log/util_bug.c @@ -74,7 +74,7 @@ tor_assertion_failed_(const char *fname, unsigned int line, const char *func, const char *expr, const char *fmt, ...) { - char buf[256]; + char *buf = NULL; char *extra = NULL; va_list ap; @@ -93,11 +93,11 @@ tor_assertion_failed_(const char *fname, unsigned int line, log_err(LD_BUG, "%s:%u: %s: Assertion %s failed; aborting.", fname, line, func, expr); - tor_snprintf(buf, sizeof(buf), - "Assertion %s failed in %s at %s:%u: %s", + tor_asprintf(&buf, "Assertion %s failed in %s at %s:%u: %s", expr, func, fname, line, extra ? extra : ""); tor_free(extra); log_backtrace(LOG_ERR, LD_BUG, buf); + tor_free(buf); } /** Helper for tor_assert_nonfatal: report the assertion failure. */ @@ -107,7 +107,7 @@ tor_bug_occurred_(const char *fname, unsigned int line, const char *func, const char *expr, int once, const char *fmt, ...) { - char buf[256]; + char *buf = NULL; const char *once_str = once ? " (Future instances of this warning will be silenced.)": ""; if (! expr) { @@ -144,12 +144,12 @@ tor_bug_occurred_(const char *fname, unsigned int line, log_warn(LD_BUG, "%s:%u: %s: Non-fatal assertion %s failed.%s", fname, line, func, expr, once_str); - tor_snprintf(buf, sizeof(buf), - "Non-fatal assertion %s failed in %s at %s:%u%s%s", + tor_asprintf(&buf, "Non-fatal assertion %s failed in %s at %s:%u%s%s", expr, func, fname, line, fmt ? " : " : "", extra); tor_free(extra); } log_backtrace(LOG_WARN, LD_BUG, buf); + tor_free(buf); #ifdef TOR_UNIT_TESTS if (failed_assertion_cb) { |