logging: avoid buffer overrun extracting arguments

The number of arguments for a format string is approximated by the
number of conversion specifications.  This count may exceed the maximum
supported argument count.  Limit the extraction to the available space.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c
index 58fd8dd..b7289b5 100644
--- a/subsys/logging/log_core.c
+++ b/subsys/logging/log_core.c
@@ -246,6 +246,7 @@
 		u32_t args[LOG_MAX_NARGS];
 		u32_t nargs = count_args(fmt);
 
+		__ASSERT_NO_MSG(nargs < LOG_MAX_NARGS);
 		for (int i = 0; i < nargs; i++) {
 			args[i] = va_arg(ap, u32_t);
 		}