xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Two coverity inspired patches for xenstored
@ 2016-07-20 14:13 Wei Liu
  2016-07-20 14:13 ` [PATCH 1/2] xenstore: send error earlier in do_mkdir Wei Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Wei Liu @ 2016-07-20 14:13 UTC (permalink / raw)
  To: Xen-devel; +Cc: Wei Liu

Wei Liu (2):
  xenstore: send error earlier in do_mkdir
  xenstore: add assertion in database dumping code

 tools/xenstore/xenstored_core.c | 7 +++++++
 1 file changed, 7 insertions(+)

-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] xenstore: send error earlier in do_mkdir
  2016-07-20 14:13 [PATCH 0/2] Two coverity inspired patches for xenstored Wei Liu
@ 2016-07-20 14:13 ` Wei Liu
  2016-07-20 14:25   ` Ian Jackson
  2016-07-20 14:13 ` [PATCH 2/2] xenstore: add assertion in database dumping code Wei Liu
  2016-07-20 15:23 ` [PATCH 0/2] Two coverity inspired patches for xenstored Wei Liu
  2 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2016-07-20 14:13 UTC (permalink / raw)
  To: Xen-devel; +Cc: Ian Jackson, Wei Liu

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] xenstore: add assertion in database dumping code
  2016-07-20 14:13 [PATCH 0/2] Two coverity inspired patches for xenstored Wei Liu
  2016-07-20 14:13 ` [PATCH 1/2] xenstore: send error earlier in do_mkdir Wei Liu
@ 2016-07-20 14:13 ` 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
  2 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2016-07-20 14:13 UTC (permalink / raw)
  To: Xen-devel; +Cc: Ian Jackson, Wei Liu

If memfile is NULL, the signal handler won't be installed, hence fopen
won't dereference NULL. Coverity is not smart enough to figure that out
unfortunately.

Add an assertion to prevent coverity from complaining.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
---
 tools/xenstore/xenstored_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index 5b2a49b..693d47d 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -2135,6 +2135,7 @@ int main(int argc, char *argv[])
 		if (trigger_talloc_report) {
 			FILE *out;
 
+			assert(memfile);
 			trigger_talloc_report = false;
 			out = fopen(memfile, "a");
 			if (out) {
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] xenstore: add assertion in database dumping code
  2016-07-20 14:13 ` [PATCH 2/2] xenstore: add assertion in database dumping code Wei Liu
@ 2016-07-20 14:24   ` Ian Jackson
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Jackson @ 2016-07-20 14:24 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel

Wei Liu writes ("[PATCH 2/2] xenstore: add assertion in database dumping code"):
> If memfile is NULL, the signal handler won't be installed, hence fopen
> won't dereference NULL. Coverity is not smart enough to figure that out
> unfortunately.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] xenstore: send error earlier in do_mkdir
  2016-07-20 14:13 ` [PATCH 1/2] xenstore: send error earlier in do_mkdir Wei Liu
@ 2016-07-20 14:25   ` Ian Jackson
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Jackson @ 2016-07-20 14:25 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel

Wei Liu writes ("[PATCH 1/2] xenstore: send error earlier in do_mkdir"):
> 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.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] Two coverity inspired patches for xenstored
  2016-07-20 14:13 [PATCH 0/2] Two coverity inspired patches for xenstored Wei Liu
  2016-07-20 14:13 ` [PATCH 1/2] xenstore: send error earlier in do_mkdir Wei Liu
  2016-07-20 14:13 ` [PATCH 2/2] xenstore: add assertion in database dumping code Wei Liu
@ 2016-07-20 15:23 ` Wei Liu
  2 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2016-07-20 15:23 UTC (permalink / raw)
  To: Xen-devel; +Cc: Wei Liu

Pushed.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-07-20 15:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-20 14:13 [PATCH 0/2] Two coverity inspired patches for xenstored Wei Liu
2016-07-20 14:13 ` [PATCH 1/2] xenstore: send error earlier in do_mkdir Wei Liu
2016-07-20 14:25   ` 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

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).