mirror of
https://github.com/SELinuxProject/selinux
synced 2025-01-01 11:12:08 +00:00
libsepol/cil: Write a message when a log message is truncated
The MAX_LOG_SIZE is 512. It is possible that a log message could exceed the max size (such as for neverallowx rules). If so, then write out "<LOG MESSAGE TRUNCATED>", so that it is obvious that the log message has been truncated. Reported-by: Jonathan Hettwer <j2468h@googlemail.com> Signed-off-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
8243b3e825
commit
5456002f1a
@ -53,8 +53,13 @@ __attribute__ ((format (printf, 2, 0))) void cil_vlog(enum cil_log_level lvl, co
|
||||
{
|
||||
if (cil_log_level >= lvl) {
|
||||
char buff[MAX_LOG_SIZE];
|
||||
vsnprintf(buff, MAX_LOG_SIZE, msg, args);
|
||||
(*cil_log_handler)(cil_log_level, buff);
|
||||
int n = vsnprintf(buff, MAX_LOG_SIZE, msg, args);
|
||||
if (n > 0) {
|
||||
(*cil_log_handler)(cil_log_level, buff);
|
||||
if (n >= MAX_LOG_SIZE) {
|
||||
(*cil_log_handler)(cil_log_level, " <LOG MESSAGE TRUNCATED>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user