From caa953cba4d2d0cdd4823eb2f1c4f24bbf18a231 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sun, 13 May 2012 22:27:07 +0200 Subject: Preconditions to check for input probs and out of memory * We don't try to guarantee completely robust and problem free behavior in cases where the caller or process isn't behaving. We consider these to be outside of our control. --- p11-kit/debug.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'p11-kit/debug.c') diff --git a/p11-kit/debug.c b/p11-kit/debug.c index 37095be..a665d0f 100644 --- a/p11-kit/debug.c +++ b/p11-kit/debug.c @@ -59,6 +59,7 @@ static struct DebugKey debug_keys[] = { }; static int debug_inited = 0; +static int debug_strict = 0; /* global variable exported in debug.h */ int _p11_debug_current_flags = ~0; @@ -72,6 +73,10 @@ parse_environ_flags (void) const char *q; int i; + env = getenv ("P11_KIT_STRICT"); + if (env && env[0] != '\0') + debug_strict = 1; + env = getenv ("P11_KIT_DEBUG"); if (!env) return 0; @@ -130,3 +135,17 @@ _p11_debug_message (int flag, fprintf (stderr, "(p11-kit:%d) %s\n", getpid(), buffer); } } + +void +_p11_debug_precond (const char *format, + ...) +{ + va_list va; + + va_start (va, format); + vfprintf (stderr, format, va); + va_end (va); + + if (debug_strict) + abort (); +} -- cgit v1.1