summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua M. Clulow <jmc@joyent.com>2014-10-22 13:01:55 -0700
committerJoshua M. Clulow <jmc@joyent.com>2014-10-26 03:57:36 +0000
commit1500d877408a2c88f70ef9f99eac98f2cb83b499 (patch)
tree34887c363a7072f3aff939a27e83e93aeea3cb64
parent429a0d603105ec7922af19cbad43a5daf7545d02 (diff)
downloadillumos-joyent-1500d877408a2c88f70ef9f99eac98f2cb83b499.tar.gz
OS-3447 lx_debug should not blow out the stack when disabled
-rw-r--r--usr/src/lib/brand/lx/lx_brand/common/debug.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr/src/lib/brand/lx/lx_brand/common/debug.c b/usr/src/lib/brand/lx/lx_brand/common/debug.c
index 6a352ee088..72472510ef 100644
--- a/usr/src/lib/brand/lx/lx_brand/common/debug.c
+++ b/usr/src/lib/brand/lx/lx_brand/common/debug.c
@@ -90,13 +90,21 @@ void
lx_debug(const char *msg, ...)
{
va_list ap;
- char buf[LX_MSG_MAXLEN + 1];
+ char *buf;
int rv, fd, n;
int errno_backup;
if (lx_debug_enabled == 0)
return;
+ /*
+ * If debugging is not enabled, we do not wish to have a large stack
+ * footprint. The buffer allocation is thus done conditionally,
+ * rather than as regular automatic storage.
+ */
+ if ((buf = SAFE_ALLOCA(LX_MSG_MAXLEN + 1)) == NULL)
+ return;
+
errno_backup = errno;
/* prefix the message with pid/tid */