diff options
author | Jes Sorensen <Jes.Sorensen@redhat.com> | 2011-11-02 22:07:21 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-11-02 22:07:21 +0100 |
commit | d94a4f62bfa7950741f320cc49475fbc8c7046a0 (patch) | |
tree | db58b4798f469f181e6f93a243fe7a17645d4053 /mdstat.c | |
parent | ping_monitor(): check file descriptor is valid before using and closing it (diff) | |
download | mdadm-d94a4f62bfa7950741f320cc49475fbc8c7046a0.tar.xz mdadm-d94a4f62bfa7950741f320cc49475fbc8c7046a0.zip |
mdstat_read(): Check return value of dup() before using file descriptor
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdstat.c')
-rw-r--r-- | mdstat.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -131,10 +131,15 @@ struct mdstat_ent *mdstat_read(int hold, int start) FILE *f; struct mdstat_ent *all, *rv, **end, **insert_here; char *line; + int fd; if (hold && mdstat_fd != -1) { lseek(mdstat_fd, 0L, 0); - f = fdopen(dup(mdstat_fd), "r"); + fd = dup(mdstat_fd); + if (fd >= 0) + f = fdopen(fd, "r"); + else + return NULL; } else f = fopen("/proc/mdstat", "r"); if (f == NULL) |