[PATCH 1/3] libshell: fix subtle section parsing bug
Jacob Keller
jacob.e.keller at intel.com
Tue May 27 15:17:17 PDT 2014
The libshell ini_config_get and ini_config_is_set functions were broken
in a subtle way, due to allowance of variables in a section which may
not be defined. When we encountered the [section] tag that matched our
given section, we enabled reading each line to check the variables.
However, we never disabled the section once we found it, so it was
possible for a variable defined in a forthcoming section to be returned,
if we didn't define the variable in the expected section.
This resulted in several subtle bugs regarding project configuration
especially regarding the [default] section, and multiple projects. The
fix for this, is simply to disable section processing upon section
change. I thought about possibly just exiting, if we've found our
section and it changes. However, that is a bit more complex logic, and
this fix allows for having the same section twice, which might be a
little confusing, but I think it's acceptable.
Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
---
helpers/libshell/shell-ini-config | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/helpers/libshell/shell-ini-config b/helpers/libshell/shell-ini-config
index ba0bfbde777a..ffce51598876 100644
--- a/helpers/libshell/shell-ini-config
+++ b/helpers/libshell/shell-ini-config
@@ -21,6 +21,8 @@ ini_config_get() {
case "$str" in
"["*"]")
+ # Reset section processing on section change
+ sect=
[ "$str" != "[$section]" ] ||
sect=1
;;
@@ -52,6 +54,8 @@ ini_config_is_set()
case "$str" in
"["*"]")
+ # Reset section processing on section change
+ sect=
[ "$str" != "[$section]" ] ||
sect=1
;;
--
1.9.0
More information about the aiaiai
mailing list