]> source.dussan.org Git - rspamd.git/commitdiff
Allow size_t values in parse_struct_integer.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 2 Sep 2013 13:26:09 +0000 (14:26 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 2 Sep 2013 13:26:09 +0000 (14:26 +0100)
src/cfg_rcl.c
src/cfg_rcl.h

index 72e9d774a283928991b01d4f2e65c1ac3af944e3..b1c7a522c9d14376d0615cdac7c4d0af9dc902c8 100644 (file)
@@ -391,6 +391,7 @@ rspamd_rcl_parse_struct_integer (struct config_file *cfg, rspamd_cl_object_t *ob
                gint32 *i32p;
                gint16 *i16p;
                gint64 *i64p;
+               gsize *sp;
        } target;
        gint64 val;
 
@@ -402,21 +403,29 @@ rspamd_rcl_parse_struct_integer (struct config_file *cfg, rspamd_cl_object_t *ob
                }
                *target.i32p = val;
        }
-       else if (pd->flags == RSPAMD_CL_FLAG_INT_16) {
-               target.i16p = (gint16 *)(((gchar *)pd->user_struct) + pd->offset);
+       else if (pd->flags == RSPAMD_CL_FLAG_INT_64) {
+               target.i64p = (gint64 *)(((gchar *)pd->user_struct) + pd->offset);
                if (!rspamd_cl_obj_toint_safe (obj, &val)) {
                        g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot convert param to integer");
                        return FALSE;
                }
-               *target.i16p = val;
+               *target.i64p = val;
        }
-       else if (pd->flags == RSPAMD_CL_FLAG_INT_64) {
-               target.i64p = (gint64 *)(((gchar *)pd->user_struct) + pd->offset);
+       else if (pd->flags == RSPAMD_CL_FLAG_SIZE) {
+               target.sp = (gsize *)(((gchar *)pd->user_struct) + pd->offset);
                if (!rspamd_cl_obj_toint_safe (obj, &val)) {
                        g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot convert param to integer");
                        return FALSE;
                }
-               *target.i64p = val;
+               *target.sp = val;
+       }
+       else if (pd->flags == RSPAMD_CL_FLAG_INT_16) {
+               target.i16p = (gint16 *)(((gchar *)pd->user_struct) + pd->offset);
+               if (!rspamd_cl_obj_toint_safe (obj, &val)) {
+                       g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot convert param to integer");
+                       return FALSE;
+               }
+               *target.i16p = val;
        }
        else {
                target.ip = (gint *)(((gchar *)pd->user_struct) + pd->offset);
index 11294e2fcc85393b8a63905f62379b7906c3d4a3..7d232cee68555025e1b9d412b5823a724e69c8da 100644 (file)
@@ -47,7 +47,8 @@ struct rspamd_rcl_struct_parser {
                RSPAMD_CL_FLAG_TIME_INTEGER = 0x1 << 3,
                RSPAMD_CL_FLAG_INT_16 = 0x1 << 4,
                RSPAMD_CL_FLAG_INT_32 = 0x1 << 5,
-               RSPAMD_CL_FLAG_INT_64 = 0x1 << 6
+               RSPAMD_CL_FLAG_INT_64 = 0x1 << 6,
+               RSPAMD_CL_FLAG_SIZE = 0x1 << 7
        } flags;
 };