[gom] gom: Check the length of parameters before saving them



commit ef24a7293d8b285b9914e7885ab3a5eefdff79e8
Author: Bastien Nocera <hadess hadess net>
Date:   Tue May 6 21:41:59 2014 +0200

    gom: Check the length of parameters before saving them
    
    Check that the primary-key and table names aren't getting clipped before
    we save them, otherwise we'll fail later at run-time.

 gom/gom-resource.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/gom/gom-resource.c b/gom/gom-resource.c
index f138031..7c7e6c9 100644
--- a/gom/gom-resource.c
+++ b/gom/gom-resource.c
@@ -52,6 +52,7 @@ gom_resource_class_set_primary_key (GomResourceClass *resource_class,
 
    g_return_if_fail(GOM_IS_RESOURCE_CLASS(resource_class));
    g_return_if_fail(primary_key != NULL);
+   g_return_if_fail(strlen(primary_key) >= sizeof(resource_class->primary_key));
 
    pspec = g_object_class_find_property(G_OBJECT_CLASS(resource_class), primary_key);
    if (!pspec) {
@@ -201,6 +202,7 @@ gom_resource_class_set_table (GomResourceClass *resource_class,
 {
    g_return_if_fail(GOM_IS_RESOURCE_CLASS(resource_class));
    g_return_if_fail(table != NULL);
+   g_return_if_fail(strlen(table) >= sizeof(resource_class->table));
 
    g_snprintf(resource_class->table,
               sizeof(resource_class->table),


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