fix a bug in the trigger handling code
authorJohn Crispin <blogic@openwrt.org>
Wed, 4 Sep 2013 12:46:49 +0000 (14:46 +0200)
committerJohn Crispin <blogic@openwrt.org>
Fri, 13 Sep 2013 15:35:55 +0000 (17:35 +0200)
Signed-off-by: John Crispin <blogic@openwrt.org>
instance.c
service.c

index e6fc33147ad053d9cbd1eba2ba6aba3718ff06b8..4230d0dddf39430da7537fcb65f96bf0044b06c3 100644 (file)
@@ -339,10 +339,10 @@ instance_config_parse(struct service_instance *in)
                in->respawn_retry = vals[2];
        }
        if (tb[INSTANCE_ATTR_TRIGGER]) {
-               in->trigger = malloc(blob_len(tb[INSTANCE_ATTR_TRIGGER]));
+               in->trigger = malloc(blob_pad_len(tb[INSTANCE_ATTR_TRIGGER]));
                if (!in->trigger)
                        return -1;
-               memcpy(in->trigger, tb[INSTANCE_ATTR_TRIGGER], blob_len(tb[INSTANCE_ATTR_TRIGGER]));
+               memcpy(in->trigger, tb[INSTANCE_ATTR_TRIGGER], blob_pad_len(tb[INSTANCE_ATTR_TRIGGER]));
                trigger_add(in->trigger, in);
        }
 
index 5647ae5e52828ac91db800e74ecb4a1f3fda511f..7776f9973743a2e1b89b9d03cc1df854fb8968fd 100644 (file)
--- a/service.c
+++ b/service.c
@@ -108,10 +108,10 @@ service_update(struct service *s, struct blob_attr *config, struct blob_attr **t
        }
 
        if (tb[SERVICE_SET_TRIGGER] && blobmsg_data_len(tb[SERVICE_SET_TRIGGER])) {
-               s->trigger = malloc(blob_len(tb[SERVICE_SET_TRIGGER]));
+               s->trigger = malloc(blob_pad_len(tb[SERVICE_SET_TRIGGER]));
                if (!s->trigger)
                        return -1;
-               memcpy(s->trigger, tb[SERVICE_SET_TRIGGER], blob_len(tb[SERVICE_SET_TRIGGER]));
+               memcpy(s->trigger, tb[SERVICE_SET_TRIGGER], blob_pad_len(tb[SERVICE_SET_TRIGGER]));
                trigger_add(s->trigger, s);
        }