summaryrefslogtreecommitdiffstats
path: root/Monitor.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2008-04-28 16:29:12 +1000
committerNeil Brown <neilb@suse.de>2008-04-28 16:29:12 +1000
commit2cdb64897d4fe33a11af13c6356dcd338c561e77 (patch)
tree9eadf9a59d00d3bed84c96701c878c6722ad4f66 /Monitor.c
parent142cb9e181b876b399c548567dad5e011ff3d0dc (diff)
downloadmdadm-2cdb64897d4fe33a11af13c6356dcd338c561e77.tar.gz
mdadm-2cdb64897d4fe33a11af13c6356dcd338c561e77.tar.xz
mdadm-2cdb64897d4fe33a11af13c6356dcd338c561e77.zip
Fix for segfault when reading /proc/mdstat
Some kernel versions don't put a space between 'active' and '(auto-read-only)' in /proc/mdstat. This causes a parsing problem leaving 'level' set to NULL which causes a crash. So synthesise a space there if it is missing, and check for 'level' to be NULL and don't de-ref if it is.
Diffstat (limited to 'Monitor.c')
-rw-r--r--Monitor.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Monitor.c b/Monitor.c
index 6b0c760..54193f5 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -403,6 +403,7 @@ int Monitor(mddev_dev_t devlist,
struct mdstat_ent *mse;
for (mse=mdstat; mse; mse=mse->next)
if (mse->devnum != INT_MAX &&
+ mse->level &&
(strcmp(mse->level, "raid0")!=0 &&
strcmp(mse->level, "linear")!=0)
) {