initscripts fkt: Check for invalid values 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:41 +02:00
committed by Michael Tremer
parent 02254f5543
commit 9f72b7bc5f
3 changed files with 14 additions and 4 deletions

View File

@@ -919,6 +919,12 @@ readhash() {
continue
fi
# Skip lines with invalid values
if ! [[ ${val} =~ ^[\'][\ A-Za-z0-9=/,.:%_@#+-]*[\']$ ]] && ! [[ ${val} =~ ^[A-Za-z0-9=/,.:%_@#+-]*$ ]]; then
echo "Invalid value '${val}' for key '${key}'" >&2
continue
fi
printf -v "${array}[${key}]" "%s" "${val}"
done < "${file}"
}