diff mbox series

[wrynose] libical: fix CVE-2026-111269

Message ID 20261130024400.3969769-1-hthakar@cisco.com
State New
Headers show
Series [wrynose] libical: fix CVE-2026-111269 | expand

Commit Message

From: Hetvi Thakar <hthakar@cisco.com>

This patch applies the upstream fix as referenced in [2],
using the commit shown in [1].

[1] https://github.com/libical/libical/commit/d753885ce2de7c105d6b8c405aa7aee1d98ad8de
[2] https://nvd.nist.gov/vuln/detail/CVE-2026-111269

Signed-off-by: Hetvi Thakar <hthakar@cisco.com>
---
 .../libical/libical/CVE-2026-111269.patch     | 107 ++++++++++++++++++
 .../recipes-support/libical/libical_3.0.20.bb |   1 +
 2 files changed, 108 insertions(+)
 create mode 100644 meta/recipes-support/libical/libical/CVE-2026-111269.patch
diff mbox series

Patch

diff --git a/meta/recipes-support/libical/libical/CVE-2026-111269.patch b/meta/recipes-support/libical/libical/CVE-2026-111269.patch
new file mode 100644
index 00000000000..fbfc0f54453
--- /dev/null
+++ b/meta/recipes-support/libical/libical/CVE-2026-111269.patch
@@ -0,0 +1,107 @@ 
+From 5300b50982f6dea8dbb744f8783fcc4955ba7168 Mon Sep 17 00:00:00 2001
+From: Alejandro <alepacheco99@gmail.com>
+Date: Thu, 15 Oct 2026 01:13:44 +0700
+Subject: [PATCH] icalvalue.c, icallangbind_p.c - fix reads past the end of a
+ string (#1455)
+
+icalvalue_decode_ical_string(): when the input ended in a backslash,
+the loop appended the terminating NUL as the escaped character, stepped
+onto it with p++, and the loop's own p++ then moved past it, so the next
+*p read beyond the string. Stop at a trailing backslash, as
+icalmemory_strdup_and_dequote() and vcardvalue_strdup_and_dequote_text()
+already do: it escapes nothing and is dropped.
+
+icallangbind_property_eval_string_r(): the newline-removal loop skipped
+a newline with i++ and copied the next character; for a value ending in
+a newline that copied the NUL and the loop's i++ then stepped past it.
+Copy every character that is not a newline instead, which also drops
+consecutive newlines as the comment says.
+
+The regression tests decode a heap copy of "a\" and evaluate a URL
+property ending in a newline, so that a read past the terminator is
+caught by AddressSanitizer.
+
+CVE: CVE-2026-111269
+Upstream-Status: Backport [https://github.com/libical/libical/commit/d753885ce2de7c105d6b8c405aa7aee1d98ad8de]
+
+Backport Changes:
+- Apply the binding loop fix to src/libical/icallangbind.c with the
+  indentation used in 3.0.20.
+- Omit CHANGELOG.md: it describes the 4.0 release and is absent from
+  3.0.20. Both source fixes and regression tests are retained.
+
+Co-authored-by: Allen Winter <winter@kde.org>
+Signed-off-by: Hetvi Thakar <hthakar@cisco.com>
+---
+ src/libical/icallangbind.c |  7 +++----
+ src/libical/icalvalue.c    |  4 ++++
+ src/test/regression.c      | 15 +++++++++++++++
+ 3 files changed, 22 insertions(+), 4 deletions(-)
+
+diff --git a/src/libical/icallangbind.c b/src/libical/icallangbind.c
+index 859d6c8..71c24f9 100644
+--- a/src/libical/icallangbind.c
++++ b/src/libical/icallangbind.c
+@@ -206,11 +206,10 @@ char *icallangbind_property_eval_string_r(icalproperty *prop, const char *sep)
+                 }
+                 /* Remove any newlines */
+ 
+-                for (j = copy, i = str; *i != 0; j++, i++) {
+-                    if (*i == '\n') {
+-                        i++;
++                for (j = copy, i = str; *i != 0; i++) {
++                    if (*i != '\n') {
++                        *j++ = *i;
+                     }
+-                    *j = *i;
+                 }
+ 
+                 *j = 0;
+diff --git a/src/libical/icalvalue.c b/src/libical/icalvalue.c
+index 99c7498..236090f 100644
+--- a/src/libical/icalvalue.c
++++ b/src/libical/icalvalue.c
+@@ -1554,6 +1554,10 @@ int icalvalue_decode_ical_string(const char *szText, char *szDecText, int nMaxBu
+ 
+     for (p = szText; *p != 0; p++) {
+         if (*p == '\\') {
++            if (*(p + 1) == 0) {
++                /* a trailing escape character escapes nothing; stop before the terminator */
++                break;
++            }
+             icalmemory_append_char(&str, &str_p, &buf_sz, *(p + 1));
+             p++;
+         } else {
+diff --git a/src/test/regression.c b/src/test/regression.c
+index 1db4922..dca256b 100644
+--- a/src/test/regression.c
++++ b/src/test/regression.c
+@@ -3814,6 +3814,12 @@ void test_langbind(void)
+            " mary@foo.org\r\n");
+ 
+     icalcomponent_free(c);
++
++    /* newlines are dropped from the value, including a trailing one */
++    p = icalproperty_new_url("http://a\n\nb\n");
++    ok("eval_string drops newlines",
++       strstr(icallangbind_property_eval_string(p, ":"), ", 'value':'http://ab'") != NULL);
++    icalproperty_free(p);
+ }
+ 
+ void test_property_parse(void)
+@@ -4621,6 +4627,15 @@ void test_icalvalue_decode_ical_string(void)
+     ok("Buffer not changed", (strcmp(buff, defvalue) == 0));
+     ok("Decodes into large-enough buffer", (icalvalue_decode_ical_string(value, buff, 3) != 0));
+     ok("Properly decoded", (strcmp(buff, "a\\") == 0));
++
++    /* Ending escape character at the very end of an allocation must not read past it */
++    {
++        char *heap = strdup("a\\");
++
++        ok("Decodes string ending in escape character", (icalvalue_decode_ical_string(heap, buff, (int)sizeof(buff)) != 0));
++        ok("Ending escape character ignored", (strcmp(buff, "a") == 0));
++        free(heap);
++    }
+ }
+ 
+ void test_icalcomponent_normalize(void)
diff --git a/meta/recipes-support/libical/libical_3.0.20.bb b/meta/recipes-support/libical/libical_3.0.20.bb
index 7f85522e91c..b63463b5a5f 100644
--- a/meta/recipes-support/libical/libical_3.0.20.bb
+++ b/meta/recipes-support/libical/libical_3.0.20.bb
@@ -15,6 +15,7 @@  SECTION = "libs"
 SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/${BP}.tar.gz \
            file://0001-cmake-Do-not-export-CC-into-gir-compiler.patch \
            file://flags.patch \
+           file://CVE-2026-111269.patch \
           "
 SRC_URI[sha256sum] = "e73de92f5a6ce84c1b00306446b290a2b08cdf0a80988eca0a2c9d5c3510b4c2"