mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
Merge branch 'giochannel-check' into 'master'
giochannel: Fix length_size bounds check Closes #2323 See merge request GNOME/glib!1931
This commit is contained in:
commit
203e078fdf
@ -899,13 +899,13 @@ g_io_channel_set_line_term (GIOChannel *channel,
|
||||
{
|
||||
/* FIXME: We’re constrained by line_term_len being a guint here */
|
||||
gsize length_size = strlen (line_term);
|
||||
g_return_if_fail (length_size > G_MAXUINT);
|
||||
g_return_if_fail (length_size <= G_MAXUINT);
|
||||
length_unsigned = (guint) length_size;
|
||||
}
|
||||
|
||||
g_free (channel->line_term);
|
||||
channel->line_term = line_term ? g_memdup2 (line_term, length_unsigned) : NULL;
|
||||
channel->line_term_len = length;
|
||||
channel->line_term_len = length_unsigned;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,8 +49,10 @@ test_read_line_embedded_nuls (void)
|
||||
channel = g_io_channel_new_file (filename, "r", &local_error);
|
||||
g_assert_no_error (local_error);
|
||||
|
||||
/* Only break on newline characters, not nuls. */
|
||||
g_io_channel_set_line_term (channel, "\n", 1);
|
||||
/* Only break on newline characters, not nuls.
|
||||
* Use length -1 here to exercise glib#2323; the case where length > 0
|
||||
* is covered in glib/tests/protocol.c. */
|
||||
g_io_channel_set_line_term (channel, "\n", -1);
|
||||
g_io_channel_set_encoding (channel, NULL, &local_error);
|
||||
g_assert_no_error (local_error);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user