Projects
openEuler:24.03
rsyslog
_service:tar_scm:rsyslog-8.37.0-initialize-vari...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:rsyslog-8.37.0-initialize-variables-and-check-return-value.patch of Package rsyslog
From 5ce33ba295e9e210aff7cb137998d8490583d516 Mon Sep 17 00:00:00 2001 From: wangshouping <wangshouping@huawei.com> Date: Wed, 15 Apr 2020 03:07:55 -0400 Subject: [PATCH] rsyslog-8.37.0-initialize-variables-and-check-return-value Signed-off-by: wangshouping <wangshouping@huawei.com> --- plugins/imjournal/imjournal.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c index 2268018..b7125a0 100644 --- a/plugins/imjournal/imjournal.c +++ b/plugins/imjournal/imjournal.c @@ -447,7 +447,7 @@ readjournal(struct journalContext_s *journalContext, ruleset_t *pBindRuleset) struct timeval tv; uint64_t timestamp; - uint64_t monotonic_timestamp; + uint64_t monotonic_timestamp = 0; struct fjson_object *json = NULL; int r; @@ -457,8 +457,8 @@ readjournal(struct journalContext_s *journalContext, ruleset_t *pBindRuleset) char *sys_iden; char *sys_iden_help = NULL; - char *t; - char *tpmessage; + char *t = NULL; + char *tpmessage = NULL; const void *get; const void *pidget; @@ -571,13 +571,17 @@ readjournal(struct journalContext_s *journalContext, ruleset_t *pBindRuleset) if (journalGetData(journalContext, "_SOURCE_MONOTONIC_TIMESTAMP", &get, &length) >= 0) { t = strndup(get+28, length-28); - monotonic_timestamp = atoll(t); - free(t); + if (t != NULL) { + monotonic_timestamp = atoll(t); + free(t); + } tpmessage = (char *)malloc(strlen(message)+30); - int ret = sprintf(tpmessage,"[%5lu.%06lu] ",monotonic_timestamp/1000000, monotonic_timestamp%1000000); - memcpy(tpmessage+(ret > 30 ? 0 :(ret < 0 ? 0:ret)),message,strlen(message)+1); - enqMsg((uchar *)tpmessage, (uchar *) sys_iden_help, facility, severity, &tv, json, 0, pBindRuleset); - free(tpmessage); + if (tpmessage != NULL) { + int ret = sprintf(tpmessage,"[%5lu.%06lu] ",monotonic_timestamp/1000000, monotonic_timestamp%1000000); + memcpy(tpmessage+(ret >= 30 ? 0 :(ret < 0 ? 0:ret)),message,strlen(message)+1); + enqMsg((uchar *)tpmessage, (uchar *) sys_iden_help, facility, severity, &tv, json, 0, pBindRuleset); + free(tpmessage); + } }else /* submit message */ enqMsg((uchar *)message, (uchar *) sys_iden_help, facility, severity, &tv, json, 0, pBindRuleset); -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2