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>
Fri, 20 May 2016 19:15:20 +0000 (15:15 -0400)
commitc6603c5ba50545e642af677581170d1deb31518c
treeebe77736a8f7585ed48933895372c5af20ad69f5
parent909881bd26b15193f27845f65f7e6010e92fb5df
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.025322 seconds and 4 git commands to generate.