Browse Source

delta: add a simple duplication check when adding delta path.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Yousong Zhou 9 years ago
parent
commit
32815cf495
2 changed files with 4 additions and 0 deletions
  1. 2 0
      delta.c
  2. 2 0
      uci.h

+ 2 - 0
delta.c

@@ -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);
 

+ 2 - 0
uci.h

@@ -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);