plugin: fix leaking invoked method name for exec plugins
[project/rpcd.git] / plugin.c
index 3740622e8fe9c753a8f2b73df341173b9642079c..fa5f09f932865a0ee1758c277eb95fdc1ef497c6 100644 (file)
--- a/plugin.c
+++ b/plugin.c
@@ -135,14 +135,14 @@ rpc_plugin_call(struct ubus_context *ctx, struct ubus_object *obj,
 {
        int rv = UBUS_STATUS_UNKNOWN_ERROR;
        struct call_context *c;
-       char *plugin;
+       char *plugin, *mptr;
 
-       c = calloc(1, sizeof(*c));
+       c = calloc_a(sizeof(*c), &mptr, strlen(method) + 1);
 
        if (!c)
                goto fail;
 
-       c->method = strdup(method);
+       c->method = strcpy(mptr, method);
        c->input = blobmsg_format_json(msg, true);
        c->tok = json_tokener_new();