summaryrefslogtreecommitdiffstats
path: root/runtime/srutils.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:54:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:54:32 +0000
commitab42b8cfd86a186447528e538ec0ae94751cfc1d (patch)
tree4fa03c118292ab8801a30fc83e53a1958426b54c /runtime/srutils.c
parentAdding upstream version 8.2404.0. (diff)
downloadrsyslog-upstream.tar.xz
rsyslog-upstream.zip
Adding upstream version 8.2406.0.upstream/8.2406.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'runtime/srutils.c')
-rw-r--r--runtime/srutils.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/runtime/srutils.c b/runtime/srutils.c
index 3369975..f949d5b 100644
--- a/runtime/srutils.c
+++ b/runtime/srutils.c
@@ -836,12 +836,25 @@ split_binary_parameters(uchar **const szBinary, char ***const __restrict__ aPara
iCnt = iStr = 0;
c = es_getBufAddr(estrParams); /* Reset to beginning */
while(iCnt < es_strlen(estrParams) ) {
- if ( c[iCnt] == ' ' && !bInQuotes ) {
- estrTmp = es_newStrFromSubStr( estrParams, iStr, iCnt-iStr);
- } else if ( iCnt+1 >= es_strlen(estrParams) ) {
- estrTmp = es_newStrFromSubStr( estrParams, iStr, iCnt-iStr+1);
- } else if (c[iCnt] == '"') {
- bInQuotes = !bInQuotes;
+ if (c[iCnt] == '"' && iCnt == iStr && !bInQuotes) {
+ bInQuotes = TRUE;
+ iStr++;
+ } else {
+ int bEOL = iCnt+1 == es_strlen(estrParams);
+ int bSpace = c[iCnt] == ' ';
+ int bQuoteEnd = bInQuotes && ((bSpace && c[iCnt-1] == '"') ||
+ (c[iCnt] == '"' && bEOL));
+ if (bEOL || bQuoteEnd || (bSpace && !bInQuotes)) {
+ int iSubCnt = iCnt - iStr;
+ if (bEOL)
+ iSubCnt++;
+ if (bQuoteEnd)
+ iSubCnt--;
+ estrTmp = es_newStrFromSubStr(estrParams, iStr, iSubCnt);
+ }
+
+ if (bQuoteEnd)
+ bInQuotes = FALSE;
}
if ( estrTmp != NULL ) {