From: Hannes Reinecke <hare@suse.de>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: dm-devel@redhat.com, Hannes Reinecke <hare@suse.com>
Subject: [PATCH] libmultipath: sanitize fd handling
Date: Fri, 15 Sep 2017 08:15:12 +0200 [thread overview]
Message-ID: <1505456112-117105-1-git-send-email-hare@suse.de> (raw)
One should remember that '0' _is_ a valid fd, so we need to set
the fd to '-1' upon allocating the path structure and ensure we're
checking for a value _smaller_ than 0 to detect an invalid fd.
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
libmultipath/checkers.c | 4 ++--
libmultipath/print.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libmultipath/checkers.c b/libmultipath/checkers.c
index 05e024f8..c32f7274 100644
--- a/libmultipath/checkers.c
+++ b/libmultipath/checkers.c
@@ -146,7 +146,7 @@ struct checker * add_checker (char *multipath_dir, char * name)
if (!c->repair)
goto out;
- c->fd = 0;
+ c->fd = -1;
c->sync = 1;
list_add(&c->node, &checkers);
return c;
@@ -237,7 +237,7 @@ int checker_check (struct checker * c)
MSG(c, "checker disabled");
return PATH_UNCHECKED;
}
- if (c->fd <= 0) {
+ if (c->fd < 0) {
MSG(c, "no usable fd");
return PATH_WILD;
}
diff --git a/libmultipath/print.c b/libmultipath/print.c
index 95dff90b..65a98247 100644
--- a/libmultipath/print.c
+++ b/libmultipath/print.c
@@ -1677,7 +1677,7 @@ int snprint_status(char *buff, int len, struct vectors *vecs)
int monitored_count = 0;
vector_foreach_slot(vecs->pathvec, pp, i)
- if (pp->fd != -1)
+ if (pp->fd >= 0)
monitored_count++;
fwd += snprintf(buff + fwd, len - fwd, "\npaths: %d\nbusy: %s\n",
monitored_count, is_uevent_busy()? "True" : "False");
--
2.12.0
next reply other threads:[~2017-09-15 6:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 6:15 Hannes Reinecke [this message]
2017-09-20 11:32 ` [PATCH] libmultipath: sanitize fd handling Martin Wilck
2017-09-20 20:24 ` Martin Wilck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1505456112-117105-1-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@redhat.com \
--cc=hare@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox