diff options
author | Mateusz Kusiak <mateusz.kusiak@intel.com> | 2024-01-18 11:28:40 +0100 |
---|---|---|
committer | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-01-24 16:14:43 +0100 |
commit | 90fd70016b99e26e116b12246631b7d4aa3d3d08 (patch) | |
tree | 648a740ed3f7b338796a55f5f041f515b82875cb /msg.c | |
parent | tests: Gate tests for linear flavor with variable LINEAR (diff) | |
download | mdadm-90fd70016b99e26e116b12246631b7d4aa3d3d08.tar.xz mdadm-90fd70016b99e26e116b12246631b7d4aa3d3d08.zip |
Define sysfs max buffer size
sysfs_get_str() usages have inconsistant buffer size.
This results in wild buffer declarations and redundant memory usage.
Define maximum buffer size for sysfs strings.
Replace wild sysfs string buffer sizes for globaly defined value.
Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Diffstat (limited to 'msg.c')
-rw-r--r-- | msg.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -324,7 +324,7 @@ int block_monitor(char *container, const int freeze) { struct mdstat_ent *ent, *e, *e2; struct mdinfo *sra = NULL; - char buf[64]; + char buf[SYSFS_MAX_BUF_SIZE]; int rv = 0; if (check_mdmon_version(container)) @@ -366,7 +366,7 @@ int block_monitor(char *container, const int freeze) !sysfs_attribute_available(sra, NULL, "sync_action")) || (freeze && sysfs_attribute_available(sra, NULL, "sync_action") && - sysfs_get_str(sra, NULL, "sync_action", buf, 20) > 0 && + sysfs_get_str(sra, NULL, "sync_action", buf, sizeof(buf)) > 0 && strcmp(buf, "frozen\n") == 0)) /* pass */; else { |