File CLBZ#5509-0001-Fix-libcrmcommon-Don-t-parse-INFINITY-as-a-list-of-c.patch of Package pacemaker.29789

From 3819b3507c14dae27275e2bbfce1da21547594d4 Mon Sep 17 00:00:00 2001
From: Reid Wahl <nrwahl@protonmail.com>
Date: Tue, 7 Mar 2023 00:48:37 -0800
Subject: [PATCH] Fix: libcrmcommon: Don't parse "-INFINITY" as a list of
 cmdline options

For the `crm_attribute -p -v -INFINITY` command, when the resource (the
`-p` argument) is specified via the OCF_RESOURCE_INSTANCE environment
variable rather than explicitly on the command line, the string
"-INFINITY" is parsed incorrectly.

pcmk__cmdline_preproc() treats the leading 'I' as an argument but skips
it because it's not in the special string. It then parses the 'N', finds
it in the special string, and treats "FINITY" as N's argument. As a
result, crm_attribute looks for a node (`-N` specifies a node) named
"FINITY" instead of treating "-INFINITY" as the value to update the
promotion score.

We should handle "-INFINITY" as a string and let GLib handle it instead.

Fixes CLBZ#5509

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
---
 lib/common/cmdline.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/common/cmdline.c b/lib/common/cmdline.c
index a9fe42b6b..08c43f79a 100644
--- a/lib/common/cmdline.c
+++ b/lib/common/cmdline.c
@@ -257,6 +257,14 @@ pcmk__cmdline_preproc(char *const *argv, const char *special) {
             continue;
         }
 
+        /* "-INFINITY" is almost certainly meant as a string, not as an option
+         * list
+         */
+        if (strcmp(argv[i], "-INFINITY") == 0) {
+            g_ptr_array_add(arr, g_strdup(argv[i]));
+            continue;
+        }
+
         /* This is a short argument, or perhaps several.  Iterate over it
          * and explode them out into individual arguments.
          */
-- 
2.35.3

openSUSE Build Service is sponsored by