From 10f7996ec29449915640acca5d65b592365a4b14 Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Tue, 26 Nov 2024 20:56:39 +0100 Subject: [PATCH] file: Ignore config file with '.' in name 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 --- file.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/file.c b/file.c index 6610f53..9db8dbd 100644 --- 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; } -- 2.30.2