ibm-s390-linux / s390-tools

Tools for use with the s390 Linux kernel and device drivers
MIT License
63 stars 59 forks source link

Call to util_file_read_l in libdasd/dasd_sys.c does not check the return code from the function #110

Closed markkp closed 3 years ago

markkp commented 3 years ago

https://github.com/ibm-s390-linux/s390-tools/blob/3d79a542d4fb4ca35c35e4431b16e6bfef465782/libdasd/dasd_sys.c#L221

If the util_file_read_l routine in libutil/util_file.c fails to read the file it is passed, it sets a return code of -1. In libdasd/dasd_sys.c, the return code is never checked, and so the variable 'value" has whatever random contents it had when dasd_get_host_access_count is entered.

Either initialize value to zero in dasd_get_host_access_count, or check the return code from util_file_read_l(&value, 10, path to determine if it was successful or not. If not, set value to zero.

hoeppnerj commented 3 years ago

Thanks for pointing this out. I've provided a fix for it. Also, I've found several other occurrences in other tools as well. Will make sure that these get fixed, too.