gobject-introspection r615 - trunk/girepository
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r615 - trunk/girepository
- Date: Fri, 19 Sep 2008 14:55:21 +0000 (UTC)
Author: walters
Date: Fri Sep 19 14:55:20 2008
New Revision: 615
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=615&view=rev
Log:
Validate the "this" argument for methods
Modified:
trunk/girepository/gtypelib.c
Modified: trunk/girepository/gtypelib.c
==============================================================================
--- trunk/girepository/gtypelib.c (original)
+++ trunk/girepository/gtypelib.c Fri Sep 19 14:55:20 2008
@@ -705,6 +705,7 @@
GTypelib *typelib = ctx->typelib;
FunctionBlob *blob;
SignatureBlob *sigblob;
+ gboolean is_method;
if (typelib->len < offset + sizeof (FunctionBlob))
{
@@ -733,6 +734,17 @@
if (!validate_name (typelib, "function symbol", typelib->data, blob->symbol, error))
return FALSE;
+
+ switch (container_type)
+ {
+ case BLOB_TYPE_BOXED:
+ case BLOB_TYPE_OBJECT:
+ case BLOB_TYPE_INTERFACE:
+ is_method = !(blob->constructor || blob->setter || blob->getter || blob->wraps_vfunc);
+ break;
+ default:
+ is_method = FALSE;
+ }
if (blob->constructor)
{
@@ -780,7 +792,6 @@
}
/* FIXME: validate index range */
- /* FIXME: validate "this" argument for methods */
if (!validate_signature_blob (typelib, blob->signature, error))
return FALSE;
@@ -810,6 +821,53 @@
return FALSE;
}
}
+ else if (is_method)
+ {
+ guint32 this_offset;
+ guint32 this_type_offset;
+ ArgBlob *this;
+ SimpleTypeBlob *thistype;
+ InterfaceTypeBlob *thistype_iface;
+
+ if (sigblob->n_arguments == 0)
+ {
+ g_set_error (error,
+ G_TYPELIB_ERROR,
+ G_TYPELIB_ERROR_INVALID,
+ "Invalid 0-argument method");
+ }
+
+ this_offset = blob->signature + sizeof (SignatureBlob);
+ this = (ArgBlob*) &typelib->data[this_offset];
+ this_type_offset = this_offset + G_STRUCT_OFFSET (ArgBlob, arg_type);
+ thistype = (SimpleTypeBlob *)&typelib->data[this_type_offset];
+
+ if (thistype->reserved == 0 &&
+ thistype->reserved2 == 0)
+ {
+ g_set_error (error,
+ G_TYPELIB_ERROR,
+ G_TYPELIB_ERROR_INVALID_BLOB,
+ "Non-reference type tag %d found for \"this\" argument",
+ thistype->tag);
+ return FALSE;
+ }
+
+ thistype_iface = (InterfaceTypeBlob*)&typelib->data[thistype->offset];
+
+ switch (thistype_iface->tag)
+ {
+ case GI_TYPE_TAG_INTERFACE:
+ break;
+ default:
+ g_set_error (error,
+ G_TYPELIB_ERROR,
+ G_TYPELIB_ERROR_INVALID_BLOB,
+ "Invalid type tag %d found for \"this\" argument",
+ thistype_iface->tag);
+ return FALSE;
+ }
+ }
pop_context (ctx);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]