Don't read beyond len. (#322520, Christian Persch)

2005-11-27  Matthias Clasen  <mclasen@redhat.com>

	* glib/gunicollate.c (g_utf8_collate_key_for_filename):
	Don't read beyond len.  (#322520, Christian Persch)
This commit is contained in:
Matthias Clasen 2005-11-27 20:15:41 +00:00 committed by Matthias Clasen
parent 9adc9c942d
commit bb5ce4b2d3
4 changed files with 20 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2005-11-27 Matthias Clasen <mclasen@redhat.com>
* glib/gunicollate.c (g_utf8_collate_key_for_filename):
Don't read beyond len. (#322520, Christian Persch)
Wed Nov 23 17:34:01 2005 Tim Janik <timj@imendio.com>
* glib/gdataset.c: access datalist flags via atomic pointer access

View File

@ -1,3 +1,8 @@
2005-11-27 Matthias Clasen <mclasen@redhat.com>
* glib/gunicollate.c (g_utf8_collate_key_for_filename):
Don't read beyond len. (#322520, Christian Persch)
Wed Nov 23 17:34:01 2005 Tim Janik <timj@imendio.com>
* glib/gdataset.c: access datalist flags via atomic pointer access

View File

@ -1,3 +1,8 @@
2005-11-27 Matthias Clasen <mclasen@redhat.com>
* glib/gunicollate.c (g_utf8_collate_key_for_filename):
Don't read beyond len. (#322520, Christian Persch)
Wed Nov 23 17:34:01 2005 Tim Janik <timj@imendio.com>
* glib/gdataset.c: access datalist flags via atomic pointer access

View File

@ -298,6 +298,7 @@ g_utf8_collate_key_for_filename (const gchar *str,
GString *append;
const gchar *p;
const gchar *prev;
const gchar *end;
gchar *collate_key;
gint digits;
gint leading_zeros;
@ -354,8 +355,10 @@ g_utf8_collate_key_for_filename (const gchar *str,
result = g_string_sized_new (len * 2);
append = g_string_sized_new (0);
end = str + len;
/* No need to use utf8 functions, since we're only looking for ascii chars */
for (prev = p = str; *p != '\0'; p++)
for (prev = p = str; p < end; p++)
{
switch (*p)
{
@ -406,10 +409,8 @@ g_utf8_collate_key_for_filename (const gchar *str,
digits = 1;
}
do
while (++p < end)
{
p++;
if (*p == '0' && !digits)
++leading_zeros;
else if (g_ascii_isdigit(*p))
@ -427,7 +428,6 @@ g_utf8_collate_key_for_filename (const gchar *str,
break;
}
}
while (*p != '\0');
while (digits > 1)
{