From d03a4fbfcd1ca64fce1efb2581a2d20bc43b38ae Mon Sep 17 00:00:00 2001 From: Milan Zamazal Date: Fri, 12 Sep 2025 16:29:14 +0200 Subject: [PATCH] config: Check configuration file version We don't know what the future versions of the configuration file will look like. The current code can process only version 1; let's check that the read configuration is of this version. Signed-off-by: Milan Zamazal Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- src/libcamera/global_configuration.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libcamera/global_configuration.cpp b/src/libcamera/global_configuration.cpp index 8b7094ee..1d6292ef 100644 --- a/src/libcamera/global_configuration.cpp +++ b/src/libcamera/global_configuration.cpp @@ -72,6 +72,15 @@ bool GlobalConfiguration::loadFile(const std::filesystem::path &fileName) return true; } + const std::optional version = (*configuration)["version"].get(); + if (version != 1) { + LOG(Configuration, Error) + << "Failed to load configuration file due to unsupported version " + << (version ? std::to_string(version.value()) : "\"unspecified\"") + << ", expected version 1"; + return true; + } + yamlConfiguration_ = std::move(configuration); return true; }