mirror of
https://github.com/systemd/systemd
synced 2024-07-22 10:44:58 +00:00
Merge pull request #2303 from aadamowski/fix-miscalculated-buffer
Fix miscalculated buffer size and uses of size-unlimited sprintf()
This commit is contained in:
commit
4a6a24be18
|
@ -326,7 +326,7 @@ void server_process_syslog_message(
|
|||
size_t label_len) {
|
||||
|
||||
char syslog_priority[sizeof("PRIORITY=") + DECIMAL_STR_MAX(int)],
|
||||
syslog_facility[sizeof("SYSLOG_FACILITY") + DECIMAL_STR_MAX(int)];
|
||||
syslog_facility[sizeof("SYSLOG_FACILITY=") + DECIMAL_STR_MAX(int)];
|
||||
const char *message = NULL, *syslog_identifier = NULL, *syslog_pid = NULL;
|
||||
struct iovec iovec[N_IOVEC_META_FIELDS + 6];
|
||||
unsigned n = 0;
|
||||
|
@ -357,11 +357,11 @@ void server_process_syslog_message(
|
|||
|
||||
IOVEC_SET_STRING(iovec[n++], "_TRANSPORT=syslog");
|
||||
|
||||
sprintf(syslog_priority, "PRIORITY=%i", priority & LOG_PRIMASK);
|
||||
snprintf(syslog_priority, sizeof(syslog_priority), "PRIORITY=%i", priority & LOG_PRIMASK);
|
||||
IOVEC_SET_STRING(iovec[n++], syslog_priority);
|
||||
|
||||
if (priority & LOG_FACMASK) {
|
||||
sprintf(syslog_facility, "SYSLOG_FACILITY=%i", LOG_FAC(priority));
|
||||
snprintf(syslog_facility, sizeof(syslog_facility), "SYSLOG_FACILITY=%i", LOG_FAC(priority));
|
||||
IOVEC_SET_STRING(iovec[n++], syslog_facility);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue