mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
The default sysfs path is always set to '/sys' unless the SYSFS_ROOT environment variable is defined. To address security concerns, secure_getenv() is used within util_path_sysfs() to protect against malicious values in SYSFS_ROOT. Additionally, constructing the sysfs path dynamically in an allocated buffer, rather than using a fixed-size buffer, helps prevent potential buffer overflows. These modifications also significantly improve testability by allowing sysfs read and write operations to be redirected to an alternative file path, which enables testing without affecting the active system state. Signed-off-by: Jan Polensky <japo@linux.ibm.com> Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>