Fix: use of uninitialized value in visit_*_decl_entry
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 19:10:37 +0000 (15:10 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:45 +0000 (12:57 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/ctf/common/metadata/visitor-generate-ir.c

index b367e6862ab261dff9b27def8e3bf3295b4334b7..badbf995bacaecbd99a97857a252372ca706cad3 100644 (file)
@@ -3037,7 +3037,8 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
 
                        ret = get_unary_unsigned(&node->u.ctf_expression.right,
                                (uint64_t *) &id);
-                       if (ret || id < 0) {
+                       /* Only read "id" if get_unary_unsigned() succeeded. */
+                       if (ret || (!ret && id < 0)) {
                                _PERROR("%s", "unexpected unary expression for event declaration's \"id\" attribute");
                                ret = -EINVAL;
                                goto error;
@@ -3061,7 +3062,11 @@ int visit_event_decl_entry(struct ctx *ctx, struct ctf_node *node,
 
                        ret = get_unary_unsigned(&node->u.ctf_expression.right,
                                (uint64_t *) stream_id);
-                       if (ret || *stream_id < 0) {
+                       /*
+                        * Only read "stream_id" if get_unary_unsigned()
+                        * succeeded.
+                        */
+                       if (ret || (!ret && *stream_id < 0)) {
                                _PERROR("%s", "unexpected unary expression for event declaration's \"stream_id\" attribute");
                                ret = -EINVAL;
                                goto error;
@@ -3575,7 +3580,8 @@ int visit_stream_decl_entry(struct ctx *ctx, struct ctf_node *node,
 
                        ret = get_unary_unsigned(&node->u.ctf_expression.right,
                                (uint64_t *) &id);
-                       if (ret || id < 0) {
+                       /* Only read "id" if get_unary_unsigned() succeeded. */
+                       if (ret || (!ret && id < 0)) {
                                _PERROR("%s", "unexpected unary expression for stream declaration's \"id\" attribute");
                                ret = -EINVAL;
                                goto error;
This page took 0.026953 seconds and 4 git commands to generate.