diff options
author | Matthias Clasen <mclasen@redhat.com> | 2004-11-29 15:39:39 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2004-11-29 15:39:39 +0000 |
commit | a9dc6decd2f71570752f6475e0ee697ffac614ce (patch) | |
tree | b16c47eac49ee8c412dff8cfad9836a1ce1abc26 | |
parent | 05ea39152ccc48cb4b3fbb69b67b471baa440710 (diff) | |
download | gtk+-a9dc6decd2f71570752f6475e0ee697ffac614ce.tar.gz |
Protect against stupid bsearch() implementations. (#159737, Morten
2004-11-29 Matthias Clasen <mclasen@redhat.com>
* xdgmimeparent.c (_xdg_mime_parent_list_lookup):
* xdgmimealias.c (_xdg_mime_alias_list_lookup): Protect
against stupid bsearch() implementations. (#159737,
Morten Welinder)
-rw-r--r-- | gtk/xdgmime/ChangeLog | 7 | ||||
-rw-r--r-- | gtk/xdgmime/xdgmimealias.c | 17 | ||||
-rw-r--r-- | gtk/xdgmime/xdgmimeparent.c | 17 |
3 files changed, 27 insertions, 14 deletions
diff --git a/gtk/xdgmime/ChangeLog b/gtk/xdgmime/ChangeLog index 3045b7278a..43a9abe10f 100644 --- a/gtk/xdgmime/ChangeLog +++ b/gtk/xdgmime/ChangeLog @@ -1,3 +1,10 @@ +2004-11-29 Matthias Clasen <mclasen@redhat.com> + + * xdgmimeparent.c (_xdg_mime_parent_list_lookup): + * xdgmimealias.c (_xdg_mime_alias_list_lookup): Protect + against stupid bsearch() implementations. (#159737, + Morten Welinder) + 2004-11-24 Matthias Clasen <mclasen@redhat.com> * xdgmimeparent.c (_xdg_mime_parent_read_from_file): diff --git a/gtk/xdgmime/xdgmimealias.c b/gtk/xdgmime/xdgmimealias.c index 70ed13a424..2be3d3711c 100644 --- a/gtk/xdgmime/xdgmimealias.c +++ b/gtk/xdgmime/xdgmimealias.c @@ -99,13 +99,16 @@ _xdg_mime_alias_list_lookup (XdgAliasList *list, XdgAlias *entry; XdgAlias key; - key.alias = (char *)alias; - key.mime_type = 0; - - entry = bsearch (&key, list->aliases, list->n_aliases, - sizeof (XdgAlias), alias_entry_cmp); - if (entry) - return entry->mime_type; + if (list->n_aliases > 0) + { + key.alias = (char *)alias; + key.mime_type = 0; + + entry = bsearch (&key, list->aliases, list->n_aliases, + sizeof (XdgAlias), alias_entry_cmp); + if (entry) + return entry->mime_type; + } return NULL; } diff --git a/gtk/xdgmime/xdgmimeparent.c b/gtk/xdgmime/xdgmimeparent.c index 9553b4b367..f623fb2d1c 100644 --- a/gtk/xdgmime/xdgmimeparent.c +++ b/gtk/xdgmime/xdgmimeparent.c @@ -104,13 +104,16 @@ _xdg_mime_parent_list_lookup (XdgParentList *list, XdgMimeParents *entry; XdgMimeParents key; - key.mime = (char *)mime; - key.parents = NULL; - - entry = bsearch (&key, list->parents, list->n_mimes, - sizeof (XdgMimeParents), &parent_entry_cmp); - if (entry) - return (const char **)entry->parents; + if (list->n_mimes > 0) + { + key.mime = (char *)mime; + key.parents = NULL; + + entry = bsearch (&key, list->parents, list->n_mimes, + sizeof (XdgMimeParents), &parent_entry_cmp); + if (entry) + return (const char **)entry->parents; + } return NULL; } |