if (!is_container && !md_array_active(fd))
goto disappeared;
- fcntl(fd, F_SETFD, FD_CLOEXEC);
+ if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
+ goto out;
+
if (md_get_array_info(fd, &array) < 0)
goto disappeared;
snprintf(st->parent_devnm, MD_NAME_MAX,
"%s", mse->metadata_version + 10);
sl = strchr(st->parent_devnm, '/');
- *sl = 0;
+ if (sl)
+ *sl = 0;
} else
st->parent_devnm[0] = 0;
*statelist = st;
return 2;
}
- strcpy(devnm, tmp);
+ snprintf(devnm, sizeof(devnm), "%s", tmp);
while(1) {
struct mdstat_ent *ms = mdstat_read(1, 0);
return 1;
}
- strcpy(devnm, fd2devnm(fd));
+ snprintf(devnm, sizeof(devnm), "%s", fd2devnm(fd));
+
mdi = sysfs_read(fd, devnm, GET_VERSION|GET_LEVEL|GET_SAFEMODE);
if (!mdi) {
if (verbose)