mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-31 06:13:29 +02:00
gfileutils: Fix OOB read in g_build_path(name)_va
If an array with more than INT_MAX elements is passed to functions internally calling g_build_path_va or g_build_pathname_va, then a signed integer overflow and eventual out of boundary read access can occur. Use size_t instead of gint for lengths and array sizes.
This commit is contained in:
@@ -1928,13 +1928,13 @@ g_build_path_va (const gchar *separator,
|
||||
gchar **str_array)
|
||||
{
|
||||
GString *result;
|
||||
gint separator_len = strlen (separator);
|
||||
size_t separator_len = strlen (separator);
|
||||
gboolean is_first = TRUE;
|
||||
gboolean have_leading = FALSE;
|
||||
const gchar *single_element = NULL;
|
||||
const gchar *next_element;
|
||||
const gchar *last_trailing = NULL;
|
||||
gint i = 0;
|
||||
size_t i = 0;
|
||||
|
||||
result = g_string_new (NULL);
|
||||
|
||||
@@ -2122,7 +2122,7 @@ g_build_pathname_va (const gchar *first_element,
|
||||
const gchar *next_element;
|
||||
const gchar *last_trailing = NULL;
|
||||
gchar current_separator = '\\';
|
||||
gint i = 0;
|
||||
size_t i = 0;
|
||||
|
||||
result = g_string_new (NULL);
|
||||
|
||||
|
Reference in New Issue
Block a user