file: Ignore config file with '.' in name
authorChristian Marangi <[email protected]>
Tue, 26 Nov 2024 19:56:39 +0000 (20:56 +0100)
committerChristian Marangi <[email protected]>
Tue, 26 Nov 2024 21:05:50 +0000 (22:05 +0100)
Uci doesn't support files with '.' in the config name and also have
parsing problems confusing option section with the actual filename.

Example:

hello.apk-new is parsed as hello filename and apk-new section

To correctly handle and prevent any kind of error, skip parsing these
file entirely. This is now needed for APK support as it does generate
config with a .apk-new suffix if a config already exist and the package
is updated.

Signed-off-by: Christian Marangi <[email protected]>
file.c

diff --git a/file.c b/file.c
index 6610f531c2f64852b032e9ead2ec30b35d61873a..9db8dbd3eeca0a4176cd4a3fcac28fe080913fc3 100644 (file)
--- a/file.c
+++ b/file.c
@@ -832,6 +832,9 @@ done:
  * after the last '/' character. By checking for a non-'\0'
  * character afterwards, directories are ignored (glob marks
  * those with a trailing '/'
+ * Filename with '.' are ignored and not parsed. Uci doesn't
+ * permit config files with '.' in the name and cause parsing
+ * problems.
  */
 static inline char *get_filename(char *path)
 {
@@ -841,6 +844,10 @@ static inline char *get_filename(char *path)
        p++;
        if (!*p)
                return NULL;
+
+       if (strrchr(p, '.'))
+               return NULL;
+
        return p;
 }