Skip to content

Commit 3caa1ca

Browse files
pabigotnashif
authored andcommitted
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 <[email protected]>
1 parent 61e084f commit 3caa1ca

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

subsys/logging/log_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ void log_generic(struct log_msg_ids src_level, const char *fmt, va_list ap)
246246
u32_t args[LOG_MAX_NARGS];
247247
u32_t nargs = count_args(fmt);
248248

249+
__ASSERT_NO_MSG(nargs < LOG_MAX_NARGS);
249250
for (int i = 0; i < nargs; i++) {
250251
args[i] = va_arg(ap, u32_t);
251252
}

0 commit comments

Comments
 (0)