From 69526998f067ed6daddb839fd035dcc218c33d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Wed, 17 Mar 2021 14:16:44 +0100 Subject: [PATCH] libdasd: Check return value for util_file_read_l MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The return code of util_file_read_l() isn't checked and therefore 'value' could contain anything in case of an error. Check the return code and set 'value' to 0 in the error case. Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/110 Reviewed-by: Stefan Haberland Signed-off-by: Jan Höppner --- libdasd/dasd_sys.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libdasd/dasd_sys.c b/libdasd/dasd_sys.c index dac2ab5c..020b52d0 100644 --- a/libdasd/dasd_sys.c +++ b/libdasd/dasd_sys.c @@ -218,7 +218,8 @@ int dasd_get_host_access_count(char *device) return 0; path = util_path_sysfs("bus/ccw/devices/%s/host_access_count", busid); - util_file_read_l(&value, 10, path); + if (util_file_read_l(&value, 10, path)) + value = 0; free(path); return value;