diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2011-03-30 22:18:03 +0800 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2011-04-05 08:59:48 +0800 |
commit | d7f6a39d2d12d9c66b94dfd58488b9c8f9aea35e (patch) | |
tree | e5f0ffef7fec73895cc41b57b3e47dccb43adab4 /libempathy-gtk/empathy-persona-view.c | |
parent | cf5ae6bf0560a62e108eb43b172e1ee837d0aa9c (diff) | |
download | gsoc2013-empathy-d7f6a39d2d12d9c66b94dfd58488b9c8f9aea35e.tar gsoc2013-empathy-d7f6a39d2d12d9c66b94dfd58488b9c8f9aea35e.tar.gz gsoc2013-empathy-d7f6a39d2d12d9c66b94dfd58488b9c8f9aea35e.tar.bz2 gsoc2013-empathy-d7f6a39d2d12d9c66b94dfd58488b9c8f9aea35e.tar.lz gsoc2013-empathy-d7f6a39d2d12d9c66b94dfd58488b9c8f9aea35e.tar.xz gsoc2013-empathy-d7f6a39d2d12d9c66b94dfd58488b9c8f9aea35e.tar.zst gsoc2013-empathy-d7f6a39d2d12d9c66b94dfd58488b9c8f9aea35e.zip |
Bug 646227 — Possible overflow in persona-view:drag_data_get
I think it was a fluke that this code worked in the first place, since it was
accessing arrays with indices which were out of range, and which wouldn't have
corresponded to the correct entries even if they were in range.
This should fix the mapping between DND types and DND URIs/atoms in the
contact list, individual and persona views.
Closes: bgo#646227
Diffstat (limited to 'libempathy-gtk/empathy-persona-view.c')
-rw-r--r-- | libempathy-gtk/empathy-persona-view.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/libempathy-gtk/empathy-persona-view.c b/libempathy-gtk/empathy-persona-view.c index 289f6fac9..6d1629651 100644 --- a/libempathy-gtk/empathy-persona-view.c +++ b/libempathy-gtk/empathy-persona-view.c @@ -84,12 +84,13 @@ enum PROP_FEATURES, }; -enum DndDragType +typedef enum { - DND_DRAG_TYPE_INDIVIDUAL_ID, + DND_DRAG_TYPE_UNKNOWN = -1, + DND_DRAG_TYPE_INDIVIDUAL_ID = 0, DND_DRAG_TYPE_PERSONA_ID, DND_DRAG_TYPE_STRING, -}; +} DndDragType; #define DRAG_TYPE(T,I) \ { (gchar *) T, 0, I } @@ -107,7 +108,6 @@ static const GtkTargetEntry drag_types_source[] = { #undef DRAG_TYPE static GdkAtom drag_atoms_dest[G_N_ELEMENTS (drag_types_dest)]; -static GdkAtom drag_atoms_source[G_N_ELEMENTS (drag_types_source)]; enum { @@ -408,10 +408,22 @@ drag_motion (GtkWidget *widget, { EmpathyPersonaView *self = EMPATHY_PERSONA_VIEW (widget); GdkAtom target; + guint i; + DndDragType drag_type = DND_DRAG_TYPE_UNKNOWN; target = gtk_drag_dest_find_target (GTK_WIDGET (self), context, NULL); - if (target == drag_atoms_dest[DND_DRAG_TYPE_INDIVIDUAL_ID]) + /* Determine the DndDragType of the data */ + for (i = 0; i < G_N_ELEMENTS (drag_atoms_dest); i++) + { + if (target == drag_atoms_dest[i]) + { + drag_type = drag_types_dest[i].info; + break; + } + } + + if (drag_type == DND_DRAG_TYPE_INDIVIDUAL_ID) { GtkTreePath *path; @@ -457,7 +469,8 @@ drag_data_get (GtkWidget *widget, return; persona_uid = folks_persona_get_uid (persona); - gtk_selection_data_set (selection, drag_atoms_source[info], 8, + gtk_selection_data_set (selection, + gdk_atom_intern ("text/persona-id", FALSE), 8, (guchar *) persona_uid, strlen (persona_uid) + 1); g_object_unref (persona); @@ -605,9 +618,6 @@ constructed (GObject *object) /* Drag & Drop. */ for (i = 0; i < G_N_ELEMENTS (drag_types_dest); ++i) drag_atoms_dest[i] = gdk_atom_intern (drag_types_dest[i].target, FALSE); - - for (i = 0; i < G_N_ELEMENTS (drag_types_source); ++i) - drag_atoms_source[i] = gdk_atom_intern (drag_types_source[i].target, FALSE); } static void |