代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/rsyslog 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 246b8d8553b6880146d6c489a28cf4bacea8a199 Mon Sep 17 00:00:00 2001
From: Rainer Gerhards <rgerhards@adiscon.com>
Date: Fri, 30 Dec 2022 17:13:17 +0100
Subject: [PATCH] core bugfix: template system may generate invalid json
When
- a list template
- is created with option.jsonf="on"
- and the last list element is a property with onEmpty="skip"
- and that property is actually empty
invalid JSON is generated.
The JSON string in this case ends with ", " instead of "}\n". This
patch fixes the issue.
closes https://github.com/rsyslog/rsyslog/issues/5050
---
Conflict:NA
Reference:https://github.com/rsyslog/rsyslog/commit/246b8d8553b6880146d6c489a28cf4bacea8a199
---
template.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/template.c b/template.c
index 21d8b8d..18bcda7 100644
--- a/template.c
+++ b/template.c
@@ -163,6 +163,7 @@ tplToString(struct template *__restrict__ const pTpl,
unsigned short bMustBeFreed = 0;
uchar *pVal;
rs_size_t iLenVal = 0;
+ int need_comma = 0;
if(pTpl->pStrgen != NULL) {
CHKiRet(pTpl->pStrgen(pMsg, iparam));
@@ -230,15 +231,24 @@ tplToString(struct template *__restrict__ const pTpl,
if(iBuf + iLenVal + extra_space >= iparam->lenBuf) /* we reserve one char for the final \0! */
CHKiRet(ExtendBuf(iparam, iBuf + iLenVal + 1));
+ if(need_comma) {
+ memcpy(iparam->param + iBuf, ", ", 2);
+ iBuf += 2;
+ }
memcpy(iparam->param + iBuf, pVal, iLenVal);
iBuf += iLenVal;
if(pTpl->optFormatEscape == JSONF) {
- memcpy(iparam->param + iBuf,
- (pTpe->pNext == NULL) ? "}\n" : ", ", 2);
- iBuf += 2;
+ need_comma = 1;
}
}
+ if((pTpl->optFormatEscape == JSONF) && (pTpe->pNext == NULL)) {
+ /* space was reserved while processing field above
+ (via extra_space in ExtendBuf() new size formula. */
+ memcpy(iparam->param + iBuf, "}\n", 2);
+ iBuf += 2;
+ }
+
if(bMustBeFreed) {
free(pVal);
bMustBeFreed = 0;
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。