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>
Thu, 19 May 2016 05:38:34 +0000 (01:38 -0400)
commit313f2aa8edc63fa6c7fbbd2e33706d891a6cc42a
treef65735b56d2d85b33c94a5822b4ed412a1e01be2
parentc5bf76dd11dd89e5467c0fc9151c88b8168ff108
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.026507 seconds and 4 git commands to generate.