public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Kalev Lember <klember@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/glib2] cve-2026-58016-f44: Backport upstream patch to fix GKeyFile group comments (rhbz#2225257)
Date: Tue, 11 Aug 2026 10:38:00 GMT	[thread overview]
Message-ID: <178644468035.1.128458195689952563.rpms-glib2-741aababcffd@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/glib2
Branch : cve-2026-58016-f44
Commit : 741aababcffd73500c998fc2d49fec291a4e3aef
Author : Kalev Lember <klember@redhat.com>
Date   : 2023-07-24T22:23:01+02:00
Stats  : +161/-0 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/glib2/c/741aababcffd73500c998fc2d49fec291a4e3aef?branch=cve-2026-58016-f44

Log:
Backport upstream patch to fix GKeyFile group comments (rhbz#2225257)

---
diff --git a/3498.patch b/3498.patch
new file mode 100644
index 0000000..dd26286
--- /dev/null
+++ b/3498.patch
@@ -0,0 +1,158 @@
+From c49502582faedecc7020155d95b16c7a1d78d432 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ga=C3=ABl=20Bonithon?= <gael@xfce.org>
+Date: Thu, 13 Jul 2023 10:06:21 +0200
+Subject: [PATCH 1/2] gkeyfile: Ensure we don't add extra blank line above new
+ group
+
+A forgotten edge case in 86b4b045: when the last value of the last group
+has been added via g_key_file_set_value() and it contains line breaks.
+The best we can do in this case is probably to do nothing.
+
+Closes: #3047
+Fixes: 86b4b0453ea3a814167d4a5f7a4031d467543716
+---
+ glib/gkeyfile.c      |  6 +++++-
+ glib/tests/keyfile.c | 10 ++++++++++
+ 2 files changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
+index 145136706f..0e21ab4f14 100644
+--- a/glib/gkeyfile.c
++++ b/glib/gkeyfile.c
+@@ -3858,8 +3858,12 @@ g_key_file_add_group (GKeyFile    *key_file,
+     {
+       /* separate groups by a blank line if we don't keep comments or group is created */
+       GKeyFileGroup *next_group = key_file->groups->next->data;
++      GKeyFileKeyValuePair *pair;
++      if (next_group->key_value_pairs != NULL)
++        pair = next_group->key_value_pairs->data;
++
+       if (next_group->key_value_pairs == NULL ||
+-          ((GKeyFileKeyValuePair *) next_group->key_value_pairs->data)->key != NULL)
++          (pair->key != NULL && !g_strstr_len (pair->value, -1, "\n")))
+         {
+           GKeyFileKeyValuePair *pair = g_new (GKeyFileKeyValuePair, 1);
+           pair->key = NULL;
+diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c
+index d3eed29841..80cdc93d8f 100644
+--- a/glib/tests/keyfile.c
++++ b/glib/tests/keyfile.c
+@@ -480,6 +480,16 @@ test_comments (void)
+                G_KEY_FILE_ERROR_GROUP_NOT_FOUND);
+   g_assert_null (comment);
+ 
++  g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/3047");
++
++  /* check if we don't add a blank line above new group if last value of preceding
++   * group was added via g_key_file_set_value() and contains line breaks */
++  g_key_file_set_value (keyfile, "group4", "key1", "value1\n\n# group comment");
++  g_key_file_set_string (keyfile, "group5", "key1", "value1");
++  comment = g_key_file_get_comment (keyfile, "group5", NULL, &error);
++  check_no_error (&error);
++  g_assert_null (comment);
++
+   g_key_file_free (keyfile);
+ }
+ 
+-- 
+GitLab
+
+
+From 51dfb3c229c0478b3615f486fbbc36de2586bd52 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ga=C3=ABl=20Bonithon?= <gael@xfce.org>
+Date: Thu, 13 Jul 2023 10:19:04 +0200
+Subject: [PATCH 2/2] gkeyfile: Skip group comment when adding a new key to a
+ group
+
+An oversight in 86b4b045: since the comment of group N now consists of
+the last null-key values of group N-1, these keys must obviously be
+skipped when adding a new non-null key to group N-1.
+
+Closes: #3047
+Fixes: 86b4b0453ea3a814167d4a5f7a4031d467543716
+---
+ glib/gkeyfile.c      | 19 ++++++++++++++-----
+ glib/tests/keyfile.c |  9 +++++++++
+ 2 files changed, 23 insertions(+), 5 deletions(-)
+
+diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
+index 0e21ab4f14..4759051977 100644
+--- a/glib/gkeyfile.c
++++ b/glib/gkeyfile.c
+@@ -573,7 +573,8 @@ static void                  g_key_file_remove_key_value_pair_node (GKeyFile
+ 
+ static void                  g_key_file_add_key_value_pair     (GKeyFile               *key_file,
+                                                                 GKeyFileGroup          *group,
+-                                                                GKeyFileKeyValuePair   *pair);
++                                                                GKeyFileKeyValuePair   *pair,
++                                                                GList                  *sibling);
+ static void                  g_key_file_add_key                (GKeyFile               *key_file,
+ 								GKeyFileGroup          *group,
+ 								const gchar            *key,
+@@ -1447,7 +1448,8 @@ g_key_file_parse_key_value_pair (GKeyFile     *key_file,
+       pair->key = g_steal_pointer (&key);
+       pair->value = g_strndup (value_start, value_len);
+ 
+-      g_key_file_add_key_value_pair (key_file, key_file->current_group, pair);
++      g_key_file_add_key_value_pair (key_file, key_file->current_group, pair,
++                                     key_file->current_group->key_value_pairs);
+     }
+ 
+   g_free (key);
+@@ -4034,10 +4036,11 @@ g_key_file_remove_group (GKeyFile     *key_file,
+ static void
+ g_key_file_add_key_value_pair (GKeyFile             *key_file,
+                                GKeyFileGroup        *group,
+-                               GKeyFileKeyValuePair *pair)
++                               GKeyFileKeyValuePair *pair,
++                               GList                *sibling)
+ {
+   g_hash_table_replace (group->lookup_map, pair->key, pair);
+-  group->key_value_pairs = g_list_prepend (group->key_value_pairs, pair);
++  group->key_value_pairs = g_list_insert_before (group->key_value_pairs, sibling, pair);
+ }
+ 
+ static void
+@@ -4047,12 +4050,18 @@ g_key_file_add_key (GKeyFile      *key_file,
+ 		    const gchar   *value)
+ {
+   GKeyFileKeyValuePair *pair;
++  GList *lp;
+ 
+   pair = g_new (GKeyFileKeyValuePair, 1);
+   pair->key = g_strdup (key);
+   pair->value = g_strdup (value);
+ 
+-  g_key_file_add_key_value_pair (key_file, group, pair);
++  /* skip group comment */
++  lp = group->key_value_pairs;
++  while (lp != NULL && ((GKeyFileKeyValuePair *) lp->data)->key == NULL)
++    lp = lp->next;
++
++  g_key_file_add_key_value_pair (key_file, group, pair, lp);
+ }
+ 
+ /**
+diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c
+index 80cdc93d8f..2c8eca4ebc 100644
+--- a/glib/tests/keyfile.c
++++ b/glib/tests/keyfile.c
+@@ -456,6 +456,15 @@ test_comments (void)
+   check_name ("group comment", comment, group_comment, 0);
+   g_free (comment);
+ 
++  g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/3047");
++
++  /* check if adding a key to group N preserve group comment of group N+1 */
++  g_key_file_set_string (keyfile, "group1", "key5", "value5");
++  comment = g_key_file_get_comment (keyfile, "group2", NULL, &error);
++  check_no_error (&error);
++  check_name ("group comment", comment, group_comment, 0);
++  g_free (comment);
++
+   g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/issues/104");
+ 
+   /* check if comments above another group than the first one are properly removed */
+-- 
+GitLab
+

diff --git a/glib2.spec b/glib2.spec
index a771419..9f63ef2 100644
--- a/glib2.spec
+++ b/glib2.spec
@@ -23,6 +23,9 @@ Patch2: gspawn-eperm.patch
 # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3504
 Patch3: fix-missing-exported-symbols.patch
 
+# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3498
+Patch4: 3498.patch
+
 BuildRequires: gcc
 BuildRequires: gcc-c++
 BuildRequires: gettext

                 reply	other threads:[~2026-08-11 10:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178644468035.1.128458195689952563.rpms-glib2-741aababcffd@fedoraproject.org \
    --to=klember@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox