Two coverity inspired patches for xenstored
cover Two coverity inspired patches for xenstored
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(+)
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
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.
---
Cc: Ian Jackson <[email protected]>
--- tools/xenstore/xenstored_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/xenstore/xenstored_core.c +6 -0
@@ -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 );
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 1/2 xenstore: send error earlier in do_mkdir
Wei Liu writes ("[PATCH 1/2] xenstore: send error earlier in do_mkdir"):
Quoted 7 lines
XenServer's coverity instance complains that a few lines below
create_nodedereferences NULL if name == NULL. It however fails to figure out that if node is NULL, errno won't be ENOENT, sodo_mkdirshould have bailed beforecreate_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.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/2 xenstore: add assertion in database dumping code
In reply to Wei LiuIf 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.
---
Cc: Ian Jackson <[email protected]>
--- tools/xenstore/xenstored_core.c | 1 + 1 file changed, 1 insertion(+)
tools/xenstore/xenstored_core.c +1 -0
@@ -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) {
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/2 xenstore: add assertion in database dumping code
Wei Liu writes ("[PATCH 2/2] xenstore: add assertion in database dumping code"):
Quoted 3 lines
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.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Pushed.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel