iwinfo: add 802.11ac hw mode
[project/rpcd.git] / uci.c
diff --git a/uci.c b/uci.c
index 3bbb9c8..acbbfd8 100644 (file)
--- a/uci.c
+++ b/uci.c
@@ -1236,11 +1236,8 @@ static int
 rpc_uci_apply_config(struct ubus_context *ctx, char *config)
 {
        struct uci_package *p = NULL;
-       struct uci_ptr ptr = { 0 };
-
-       ptr.package = config;
 
-       if (!uci_load(cursor, ptr.package, &p)) {
+       if (!uci_load(cursor, config, &p)) {
                uci_commit(cursor, &p, false);
                uci_unload(cursor, p);
        }
@@ -1392,6 +1389,10 @@ rpc_uci_apply(struct ubus_context *ctx, struct ubus_object *obj,
                        return ret;
                }
 
+               /* copy SID early because rpc_uci_apply_config() will clobber buf */
+               if (rollback)
+                       strncpy(apply_sid, sid, RPC_SID_LEN);
+
                for (i = 0; i < gl.gl_pathc; i++) {
                        char *config = basename(gl.gl_pathv[i]);
                        struct stat s;
@@ -1410,7 +1411,6 @@ rpc_uci_apply(struct ubus_context *ctx, struct ubus_object *obj,
                globfree(&gl);
 
                if (rollback) {
-                       strncpy(apply_sid, sid, RPC_SID_LEN);
                        apply_timer.cb = rpc_uci_apply_timeout;
                        uloop_timeout_set(&apply_timer, timeout * 1000);
                        apply_ctx = ctx;