fix filename validation
[project/uci.git] / file.c
diff --git a/file.c b/file.c
index ae58fbc..6cc2eae 100644 (file)
--- a/file.c
+++ b/file.c
  * This file contains the code for parsing uci config files
  */
 
+#define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/file.h>
 #include <stdbool.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -779,7 +781,6 @@ int uci_load(struct uci_context *ctx, const char *name, struct uci_package **pac
        FILE *file = NULL;
 
        UCI_HANDLE_ERR(ctx);
-       UCI_ASSERT(ctx, uci_validate_name(name));
 
        switch (name[0]) {
        case '.':
@@ -795,6 +796,7 @@ int uci_load(struct uci_context *ctx, const char *name, struct uci_package **pac
                break;
        default:
                /* config in /etc/config */
+               UCI_ASSERT(ctx, uci_validate_name(name));
                filename = uci_config_path(ctx, name);
                confdir = true;
                break;