initscripts fkt: ignore invalid keys in readhash

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Jonatan Schlag
2024-06-16 18:02:40 +02:00
committed by Michael Tremer
parent d289bc28be
commit 02254f5543
5 changed files with 46 additions and 0 deletions

View File

@@ -913,6 +913,12 @@ readhash() {
local key="${line%=*}"
local val="${line#*=}"
# Skip lines with an invalid key
if ! [[ ${key} =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then
echo "Invalid key '${key}'" >&2
continue
fi
printf -v "${array}[${key}]" "%s" "${val}"
done < "${file}"
}