Fix: Deference after null check in sessiond set_option
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 18 May 2016 17:20:08 +0000 (13:20 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 18 May 2016 17:20:08 +0000 (13:20 -0400)
commit66b2ce8e87e53e5f69446a70b3a4d90399095930
tree78de970ae21bb6d9fd264a72ca0c264fc65d161b
parent5cfbc08ca9e36ca0d5cac64e2c448cdb5cb863a7
Fix: Deference after null check in sessiond set_option

Found by Coverity:

2. var_compare_op: Comparing arg to null implies that arg might be null.

CID 1256137 (#1 of 9): Dereference after null check (FORWARD_NULL)14.
var_deref_model: Passing null pointer arg to strdup, which dereferences
it.

[... same for #2 through #9 ]

This should not really be an issue since
1) options that use the "arg" parameter will not be set by popt if one
   is not provided,
2) the configuration file parser will never invoke set_option with
   a NULL argument; if no "value" is provided in the file, an empty
   string is passed.

The second point is the reason for the "arg && arg[0] == '\0'" check;
we already know that the argument is invalid since an empty string
is never a valid argument for the supported options.

Nonetheless, it makes sense for Coverity to flag this and moving
the check to individual cases, although very verbose, is clear.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/main.c
This page took 0.028237 seconds and 5 git commands to generate.