diff options
Diffstat (limited to 'meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-11.patch')
-rw-r--r-- | meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-11.patch | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-11.patch b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-11.patch new file mode 100644 index 0000000000..a620a49269 --- /dev/null +++ b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2021-27219-11.patch | |||
@@ -0,0 +1,63 @@ | |||
1 | From ecdf91400e9a538695a0895b95ad7e8abcdf1749 Mon Sep 17 00:00:00 2001 | ||
2 | From: Philip Withnall <pwithnall@endlessos.org> | ||
3 | Date: Thu, 4 Feb 2021 14:09:40 +0000 | ||
4 | Subject: [PATCH 11/11] giochannel: Forbid very long line terminator strings | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | The public API `GIOChannel.line_term_len` is only a `guint`. Ensure that | ||
10 | nul-terminated strings passed to `g_io_channel_set_line_term()` can’t | ||
11 | exceed that length. Use `g_memdup2()` to avoid a warning (`g_memdup()` | ||
12 | is due to be deprecated), but not to avoid a bug, since it’s also | ||
13 | limited to `G_MAXUINT`. | ||
14 | |||
15 | Signed-off-by: Philip Withnall <pwithnall@endlessos.org> | ||
16 | Helps: #2319 | ||
17 | |||
18 | Upstream-Status: Backport [https://mirrors.ocf.berkeley.edu/ubuntu/pool/main/g/glib2.0/glib2.0_2.64.6-1~ubuntu20.04.3.debian.tar.xz] | ||
19 | CVE: CVE-2021-27219 | ||
20 | Signed-off-by: Neetika Singh <Neetika.Singh@kpit.com> | ||
21 | Signed-off-by: Ranjitsinh Rathod <ranjitsinh.rathod@kpit.com> | ||
22 | |||
23 | --- | ||
24 | glib/giochannel.c | 17 +++++++++++++---- | ||
25 | 1 file changed, 13 insertions(+), 4 deletions(-) | ||
26 | |||
27 | diff --git a/glib/giochannel.c b/glib/giochannel.c | ||
28 | index c6a89d6e0..4dec20f77 100644 | ||
29 | --- a/glib/giochannel.c | ||
30 | +++ b/glib/giochannel.c | ||
31 | @@ -887,16 +887,25 @@ g_io_channel_set_line_term (GIOChannel *channel, | ||
32 | const gchar *line_term, | ||
33 | gint length) | ||
34 | { | ||
35 | + guint length_unsigned; | ||
36 | + | ||
37 | g_return_if_fail (channel != NULL); | ||
38 | g_return_if_fail (line_term == NULL || length != 0); /* Disallow "" */ | ||
39 | |||
40 | if (line_term == NULL) | ||
41 | - length = 0; | ||
42 | - else if (length < 0) | ||
43 | - length = strlen (line_term); | ||
44 | + length_unsigned = 0; | ||
45 | + else if (length >= 0) | ||
46 | + length_unsigned = (guint) length; | ||
47 | + else | ||
48 | + { | ||
49 | + /* FIXME: We’re constrained by line_term_len being a guint here */ | ||
50 | + gsize length_size = strlen (line_term); | ||
51 | + g_return_if_fail (length_size > G_MAXUINT); | ||
52 | + length_unsigned = (guint) length_size; | ||
53 | + } | ||
54 | |||
55 | g_free (channel->line_term); | ||
56 | - channel->line_term = line_term ? g_memdup (line_term, length) : NULL; | ||
57 | + channel->line_term = line_term ? g_memdup2 (line_term, length_unsigned) : NULL; | ||
58 | channel->line_term_len = length; | ||
59 | } | ||
60 | |||
61 | -- | ||
62 | GitLab | ||
63 | |||