[glib] gbookmarkfile: check length before dereferencing groups



commit 17e03effdac249b84153bf2d9b0d665078129873
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jan 8 22:13:03 2018 -0800

    gbookmarkfile: check length before dereferencing groups
    
    There is no requirement that groups is NULL terminated, so we should check
    that the bounds are within the specified length before checking for a
    NULL terminating value.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792351

 glib/gbookmarkfile.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c
index 92a5e0f..4661b9d 100644
--- a/glib/gbookmarkfile.c
+++ b/glib/gbookmarkfile.c
@@ -2862,7 +2862,7 @@ g_bookmark_file_set_groups (GBookmarkFile  *bookmark,
   
   if (groups)
     {
-      for (i = 0; groups[i] != NULL && i < length; i++)
+      for (i = 0; i < length && groups[i] != NULL; i++)
         item->metadata->groups = g_list_append (item->metadata->groups,
                                                g_strdup (groups[i]));
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]