diff options
author | Yousong Zhou <yszhou4tech@gmail.com> | 2014-12-16 15:00:14 +0800 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-12-18 12:38:15 +0100 |
commit | 32815cf4959c3219b8b6051efcf045c0d829dc10 (patch) | |
tree | 45e7a581ed05cda26b10b7b1ea9edc91e39fd0a9 | |
parent | ec302c635b27e212c2df5ce3378fd94edfbfd886 (diff) | |
download | uci-32815cf4959c3219b8b6051efcf045c0d829dc10.tar.gz |
delta: add a simple duplication check when adding delta path.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-rw-r--r-- | delta.c | 2 | ||||
-rw-r--r-- | uci.h | 2 |
2 files changed, 4 insertions, 0 deletions
@@ -87,6 +87,8 @@ int uci_add_delta_path(struct uci_context *ctx, const char *dir) UCI_HANDLE_ERR(ctx); UCI_ASSERT(ctx, dir != NULL); + if (!strcmp(dir, ctx->savedir)) + return -1; e = uci_alloc_generic(ctx, UCI_TYPE_PATH, dir, sizeof(struct uci_element)); uci_list_add(&ctx->delta_path, &e->list); @@ -262,6 +262,8 @@ extern int uci_set_confdir(struct uci_context *ctx, const char *dir); * * This function allows you to add directories, which contain 'overlays' * for the active config, that will never be committed. + * Caller of this API should ensure that no duplicate entries (including the + * default search path, e.g. `UCI_SAVEDIR') should be added. */ extern int uci_add_delta_path(struct uci_context *ctx, const char *dir); |