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 /managemon.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 'managemon.c')
-rw-r--r-- | managemon.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/managemon.c b/managemon.c index a7bfa8f6..358459e7 100644 --- a/managemon.c +++ b/managemon.c @@ -454,7 +454,7 @@ static void manage_member(struct mdstat_ent *mdstat, * trying to find and assign a spare. * We do that whenever the monitor tells us too. */ - char buf[64]; + char buf[SYSFS_MAX_BUF_SIZE]; int frozen; struct supertype *container = a->container; struct mdinfo *mdi; @@ -664,7 +664,7 @@ static void manage_new(struct mdstat_ent *mdstat, struct mdinfo *mdi = NULL, *di; int i, inst; int failed = 0; - char buf[40]; + char buf[SYSFS_MAX_BUF_SIZE]; /* check if array is ready to be monitored */ if (!mdstat->active || !mdstat->level) @@ -738,7 +738,7 @@ static void manage_new(struct mdstat_ent *mdstat, * read this information for new arrays only (empty victim) */ if ((victim == NULL) && - (sysfs_get_str(mdi, NULL, "sync_action", buf, 40) > 0) && + (sysfs_get_str(mdi, NULL, "sync_action", buf, sizeof(buf)) > 0) && (strncmp(buf, "reshape", 7) == 0)) { if (sysfs_get_ll(mdi, NULL, "reshape_position", &new->last_checkpoint) != 0) |