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)
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>

No differences found
This page took 0.028838 seconds and 4 git commands to generate.