From c80009a5f56550483c1f1f0b4fdae9c040abd0ae Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 25 May 2014 20:55:30 +0200 Subject: service: use blob_memdup() Signed-off-by: Felix Fietkau --- service/instance.c | 3 +-- service/service.c | 3 +-- service/trigger.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/service/instance.c b/service/instance.c index 1b28a7a..4a45759 100644 --- a/service/instance.c +++ b/service/instance.c @@ -408,10 +408,9 @@ instance_config_parse(struct service_instance *in) in->respawn_retry = vals[2]; } if (tb[INSTANCE_ATTR_TRIGGER]) { - in->trigger = malloc(blob_pad_len(tb[INSTANCE_ATTR_TRIGGER])); + in->trigger = blob_memdup(tb[INSTANCE_ATTR_TRIGGER]); if (!in->trigger) return -1; - memcpy(in->trigger, tb[INSTANCE_ATTR_TRIGGER], blob_pad_len(tb[INSTANCE_ATTR_TRIGGER])); trigger_add(in->trigger, in); } diff --git a/service/service.c b/service/service.c index 3fc8424..c566bc7 100644 --- a/service/service.c +++ b/service/service.c @@ -117,10 +117,9 @@ service_update(struct service *s, struct blob_attr *config, struct blob_attr **t service_validate_del(s); if (tb[SERVICE_SET_TRIGGER] && blobmsg_data_len(tb[SERVICE_SET_TRIGGER])) { - s->trigger = malloc(blob_pad_len(tb[SERVICE_SET_TRIGGER])); + s->trigger = blob_memdup(tb[SERVICE_SET_TRIGGER]); if (!s->trigger) return -1; - memcpy(s->trigger, tb[SERVICE_SET_TRIGGER], blob_pad_len(tb[SERVICE_SET_TRIGGER])); trigger_add(s->trigger, s); } diff --git a/service/trigger.c b/service/trigger.c index 41fb55d..b7bdbc5 100644 --- a/service/trigger.c +++ b/service/trigger.c @@ -323,8 +323,7 @@ void trigger_event(char *type, struct blob_attr *data) continue; if (!strcmp(t->type, type)) { if (t->timeout) { - t->data = malloc(blob_pad_len(data)); - memcpy(t->data, data, blob_pad_len(data)); + t->data = blob_memdup(data); uloop_timeout_set(&t->delay, t->timeout); } else { json_script_run(&t->jctx, "foo", data); -- cgit v1.2.3