[Swfdec] 2 commits - libswfdec/swfdec_flash_security.c libswfdec/swfdec_flash_security.h libswfdec/swfdec_net_stream.c libswfdec/swfdec_player.c libswfdec/swfdec_resource_request.c libswfdec/swfdec_resource_request.h libswfdec/swfdec_security.h
Pekka Lampila
medar at kemper.freedesktop.org
Thu Dec 13 11:02:28 PST 2007
libswfdec/swfdec_flash_security.c | 49 +++++++++++++++++++++++-------------
libswfdec/swfdec_flash_security.h | 7 ++---
libswfdec/swfdec_net_stream.c | 2 -
libswfdec/swfdec_player.c | 2 +
libswfdec/swfdec_resource_request.c | 28 +++++++++++++++++---
libswfdec/swfdec_resource_request.h | 2 +
libswfdec/swfdec_security.h | 2 -
7 files changed, 66 insertions(+), 26 deletions(-)
New commits:
commit fe10412fcc1698adf61b19fdf55fc25be7248651
Merge: dff3ed0... 9eb2e0d...
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Dec 13 19:47:47 2007 +0200
Merge branch 'master' of ssh://medar@git.freedesktop.org/git/swfdec/swfdec
Conflicts:
libswfdec/swfdec_player.c
diff --cc libswfdec/swfdec_player.c
index 5db8a3e,efe2798..8191f6a
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@@ -838,18 -860,16 +860,18 @@@ swfdec_player_dispose (GObject *object
swfdec_player_stop_all_sounds (player);
swfdec_player_resource_request_finish (player);
- g_hash_table_destroy (player->registered_classes);
+ g_hash_table_destroy (priv->registered_classes);
- while (player->roots)
- swfdec_movie_destroy (player->roots->data);
- if (player->resource) {
+ while (priv->roots)
+ swfdec_movie_destroy (priv->roots->data);
+ if (priv->resource) {
+ swfdec_flash_security_free_pending (
- SWFDEC_FLASH_SECURITY (player->resource));
- g_object_unref (player->resource);
- player->resource = NULL;
++ SWFDEC_FLASH_SECURITY (priv->resource));
+ g_object_unref (priv->resource);
+ priv->resource = NULL;
}
- while (player->rooted_objects)
- swfdec_player_unroot_object (player, player->rooted_objects->data);
+ while (priv->rooted_objects)
+ swfdec_player_unroot_object (player, priv->rooted_objects->data);
/* we do this here so references to GC'd objects get freed */
G_OBJECT_CLASS (swfdec_player_parent_class)->dispose (object);
diff --cc libswfdec/swfdec_resource_request.c
index f5bb5fc,020625d..8c3ddbf
--- a/libswfdec/swfdec_resource_request.c
+++ b/libswfdec/swfdec_resource_request.c
@@@ -138,22 -128,12 +138,22 @@@ swfdec_request_resource_perform_load_ca
}
static void
+swfdec_request_resource_perform_load_abort_callback (SwfdecPlayer *player,
+ gpointer data)
+{
+ SwfdecResourceRequest *request = data;
+
+ swfdec_resource_request_free (request);
+}
+
+static void
swfdec_request_resource_perform_load (SwfdecPlayer *player, SwfdecResourceRequest *request)
{
- g_assert (player->resource);
+ g_assert (player->priv->resource);
swfdec_player_request_resource_now (player, request->security,
request->url, request->request, request->buffer,
- swfdec_request_resource_perform_load_callback, request);
+ swfdec_request_resource_perform_load_callback,
+ swfdec_request_resource_perform_load_abort_callback, request);
}
static void
commit dff3ed08822801e44702d463601a809bf3edde78
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date: Thu Dec 13 18:00:33 2007 +0200
Fix freeing of policy loader related resources
Fixes crash bug 13607
This is somewhat ugly. Will have to rework the whole thing soon
diff --git a/libswfdec/swfdec_flash_security.c b/libswfdec/swfdec_flash_security.c
index 03f15a4..21fe688 100644
--- a/libswfdec/swfdec_flash_security.c
+++ b/libswfdec/swfdec_flash_security.c
@@ -158,13 +158,13 @@ swfdec_flash_security_allow_cross_domain (SwfdecFlashSecurity *sec,
if (g_slist_find_custom (sec->crossdomain_allowed, host,
(GCompareFunc)g_ascii_strcasecmp)) {
- callback (url, TRUE, user_data);
+ callback (url, 1, user_data);
return;
}
if (g_slist_find_custom (sec->crossdomain_denied, host,
(GCompareFunc)g_ascii_strcasecmp)) {
- callback (url, FALSE, user_data);
+ callback (url, 0, user_data);
return;
}
@@ -183,17 +183,17 @@ swfdec_flash_security_allow_url (SwfdecSecurity *guard, const SwfdecURL *url,
SwfdecURLAllowFunc callback, gpointer user_data)
{
SwfdecFlashSecurity *sec = SWFDEC_FLASH_SECURITY (guard);
- gboolean allowed;
+ int status;
switch (sec->sandbox) {
case SWFDEC_SANDBOX_NONE:
- allowed = FALSE;
+ status = 0;
break;
case SWFDEC_SANDBOX_REMOTE:
if (swfdec_url_is_local (url)) {
- allowed = FALSE;
+ status = 0;
} else if (swfdec_flash_security_match_domain (sec->url, url)) {
- allowed = TRUE;
+ status = 1;
} else {
swfdec_flash_security_allow_cross_domain (sec, url, callback,
user_data);
@@ -201,11 +201,15 @@ swfdec_flash_security_allow_url (SwfdecSecurity *guard, const SwfdecURL *url,
}
break;
case SWFDEC_SANDBOX_LOCAL_FILE:
- allowed = swfdec_url_is_local (url);
+ if (swfdec_url_is_local (url)) {
+ status = 1;
+ } else {
+ status = 0;
+ }
break;
case SWFDEC_SANDBOX_LOCAL_NETWORK:
if (swfdec_url_is_local (url)) {
- allowed = FALSE;
+ status = 0;
} else {
swfdec_flash_security_allow_cross_domain (sec, url, callback,
user_data);
@@ -213,15 +217,30 @@ swfdec_flash_security_allow_url (SwfdecSecurity *guard, const SwfdecURL *url,
}
break;
case SWFDEC_SANDBOX_LOCAL_TRUSTED:
- allowed = TRUE;
+ status = 1;
break;
default:
g_assert_not_reached ();
- allowed = FALSE;
+ status = 0;
break;
}
- callback (url, allowed, user_data);
+ callback (url, status, user_data);
+}
+
+void
+swfdec_flash_security_free_pending (SwfdecFlashSecurity *sec)
+{
+ GSList *iter;
+
+ for (iter = sec->allow_url_pending; iter != NULL; iter = iter->next) {
+ SwfdecAllowURLPending *pending = iter->data;
+ pending->callback (pending->url, -1, pending->user_data);
+ swfdec_url_free (pending->url);
+ g_free (pending);
+ }
+ g_slist_free (sec->allow_url_pending);
+ sec->allow_url_pending = NULL;
}
static void
@@ -230,6 +249,8 @@ swfdec_flash_security_dispose (GObject *object)
SwfdecFlashSecurity *sec = SWFDEC_FLASH_SECURITY (object);
GSList *iter;
+ g_assert (sec->allow_url_pending == NULL);
+
for (iter = sec->policy_loaders; iter != NULL; iter = iter->next) {
swfdec_policy_loader_free (iter->data);
}
@@ -248,12 +269,6 @@ swfdec_flash_security_dispose (GObject *object)
g_slist_free (sec->crossdomain_denied);
sec->crossdomain_denied = NULL;
- for (iter = sec->allow_url_pending; iter != NULL; iter = iter->next) {
- g_free (iter->data);
- }
- g_slist_free (sec->allow_url_pending);
- sec->allow_url_pending = NULL;
-
if (sec->url) {
swfdec_url_free (sec->url);
sec->url = NULL;
diff --git a/libswfdec/swfdec_flash_security.h b/libswfdec/swfdec_flash_security.h
index 227de2b..fcb2aaf 100644
--- a/libswfdec/swfdec_flash_security.h
+++ b/libswfdec/swfdec_flash_security.h
@@ -63,10 +63,11 @@ struct _SwfdecFlashSecurityClass
SwfdecSecurityClass security_class;
};
-GType swfdec_flash_security_get_type (void);
+GType swfdec_flash_security_get_type (void);
-void swfdec_flash_security_set_url (SwfdecFlashSecurity * sec,
- const SwfdecURL * url);
+void swfdec_flash_security_set_url (SwfdecFlashSecurity * sec,
+ const SwfdecURL * url);
+void swfdec_flash_security_free_pending (SwfdecFlashSecurity * sec);
G_END_DECLS
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index 35c8c8e..775974a 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -494,7 +494,7 @@ swfdec_net_stream_set_url (SwfdecNetStream *stream, const char *url)
g_assert (cx->frame);
swfdec_player_request_resource_now (SWFDEC_PLAYER (cx), cx->frame->security,
url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL,
- swfdec_net_stream_request_callback, stream);
+ swfdec_net_stream_request_callback, NULL, stream);
}
void
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 2c5f47c..5db8a3e 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -843,6 +843,8 @@ swfdec_player_dispose (GObject *object)
while (player->roots)
swfdec_movie_destroy (player->roots->data);
if (player->resource) {
+ swfdec_flash_security_free_pending (
+ SWFDEC_FLASH_SECURITY (player->resource));
g_object_unref (player->resource);
player->resource = NULL;
}
diff --git a/libswfdec/swfdec_resource_request.c b/libswfdec/swfdec_resource_request.c
index 7b17d12..f5bb5fc 100644
--- a/libswfdec/swfdec_resource_request.c
+++ b/libswfdec/swfdec_resource_request.c
@@ -53,17 +53,25 @@ typedef struct {
SwfdecLoaderRequest request;
SwfdecBuffer * buffer;
SwfdecResourceFunc callback;
+ SwfdecResourceAbortFunc abort;
gpointer user_data;
} AllowCallbackData;
static void
swfdec_player_request_resource_allow_callback (const SwfdecURL *url,
- gboolean allowed, gpointer data_)
+ int status, gpointer data_)
{
AllowCallbackData *data = data_;
SwfdecLoader *loader;
- if (!allowed) {
+ if (status < 0) {
+ if (data->abort != NULL)
+ data->abort (data->player, data->user_data);
+ g_free (data);
+ return;
+ }
+
+ if (status == 0) {
SWFDEC_ERROR ("not allowing access to %s", swfdec_url_get_url (url));
loader = NULL;
} else {
@@ -85,7 +93,8 @@ swfdec_player_request_resource_allow_callback (const SwfdecURL *url,
void
swfdec_player_request_resource_now (SwfdecPlayer *player,
SwfdecSecurity *security, const char *url, SwfdecLoaderRequest req,
- SwfdecBuffer *buffer, SwfdecResourceFunc callback, gpointer user_data)
+ SwfdecBuffer *buffer, SwfdecResourceFunc callback,
+ SwfdecResourceAbortFunc abort, gpointer user_data)
{
SwfdecURL *absolute;
AllowCallbackData *data;
@@ -99,6 +108,7 @@ swfdec_player_request_resource_now (SwfdecPlayer *player,
data->request = req;
data->buffer = buffer;
data->callback = callback;
+ data->abort = abort;
data->user_data = user_data;
/* create absolute url first */
@@ -128,12 +138,22 @@ swfdec_request_resource_perform_load_callback (SwfdecPlayer *player,
}
static void
+swfdec_request_resource_perform_load_abort_callback (SwfdecPlayer *player,
+ gpointer data)
+{
+ SwfdecResourceRequest *request = data;
+
+ swfdec_resource_request_free (request);
+}
+
+static void
swfdec_request_resource_perform_load (SwfdecPlayer *player, SwfdecResourceRequest *request)
{
g_assert (player->resource);
swfdec_player_request_resource_now (player, request->security,
request->url, request->request, request->buffer,
- swfdec_request_resource_perform_load_callback, request);
+ swfdec_request_resource_perform_load_callback,
+ swfdec_request_resource_perform_load_abort_callback, request);
}
static void
diff --git a/libswfdec/swfdec_resource_request.h b/libswfdec/swfdec_resource_request.h
index dffa2b4..af9c7c7 100644
--- a/libswfdec/swfdec_resource_request.h
+++ b/libswfdec/swfdec_resource_request.h
@@ -27,6 +27,7 @@ G_BEGIN_DECLS
typedef struct _SwfdecResourceRequest SwfdecResourceRequest;
typedef void (* SwfdecResourceFunc) (SwfdecPlayer *player, SwfdecLoader *loader, gpointer data);
+typedef void (* SwfdecResourceAbortFunc) (SwfdecPlayer *player, gpointer data);
typedef void (* SwfdecResourceUnloadFunc) (SwfdecPlayer *player, const char *target, gpointer data);
typedef enum {
@@ -75,6 +76,7 @@ void swfdec_player_request_resource_now (SwfdecPlayer * player,
SwfdecLoaderRequest req,
SwfdecBuffer * buffer,
SwfdecResourceFunc callback,
+ SwfdecResourceAbortFunc abort,
gpointer user_data);
void swfdec_player_request_unload (SwfdecPlayer * player,
const char * target,
diff --git a/libswfdec/swfdec_security.h b/libswfdec/swfdec_security.h
index cb89f57..2933b44 100644
--- a/libswfdec/swfdec_security.h
+++ b/libswfdec/swfdec_security.h
@@ -28,7 +28,7 @@ G_BEGIN_DECLS
typedef struct _SwfdecSecurity SwfdecSecurity;
typedef struct _SwfdecSecurityClass SwfdecSecurityClass;
-typedef void (* SwfdecURLAllowFunc) (const SwfdecURL *url, gboolean allowed, gpointer data);
+typedef void (* SwfdecURLAllowFunc) (const SwfdecURL *url, int status, gpointer data);
#define SWFDEC_TYPE_SECURITY (swfdec_security_get_type())
#define SWFDEC_IS_SECURITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SECURITY))
More information about the Swfdec
mailing list