From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>, Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH 1/2] xenstore: send error earlier in do_mkdir
Date: Wed, 20 Jul 2016 15:13:41 +0100 [thread overview]
Message-ID: <1469024022-6505-2-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1469024022-6505-1-git-send-email-wei.liu2@citrix.com>
XenServer's coverity instance complains that a few lines below
create_node dereferences NULL if name == NULL. It however fails to
figure out that if node is NULL, errno won't be ENOENT, so do_mkdir
should have bailed before create_node.
That said, it would be good if we don't need to go through the hops. We
can bail earlier if name is NULL.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
---
tools/xenstore/xenstored_core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index ffc0634..5b2a49b 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -981,6 +981,12 @@ static void do_mkdir(struct connection *conn, struct buffered_data *in)
struct node *node;
const char *name = onearg(in);
+ if (!name) {
+ errno = EINVAL;
+ send_error(conn, errno);
+ return;
+ }
+
name = canonicalize(conn, name);
node = get_node(conn, in, name, XS_PERM_WRITE);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-07-20 14:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-20 14:13 [PATCH 0/2] Two coverity inspired patches for xenstored Wei Liu
2016-07-20 14:13 ` Wei Liu [this message]
2016-07-20 14:25 ` [PATCH 1/2] xenstore: send error earlier in do_mkdir Ian Jackson
2016-07-20 14:13 ` [PATCH 2/2] xenstore: add assertion in database dumping code Wei Liu
2016-07-20 14:24 ` Ian Jackson
2016-07-20 15:23 ` [PATCH 0/2] Two coverity inspired patches for xenstored Wei Liu
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=1469024022-6505-2-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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;
as well as URLs for NNTP newsgroup(s).