X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fmain.c;h=a3e08ec514170242db9ab67118c92fae2bea89fc;hb=165aa49a26f9f5e53d8f87f092b8ebb6d441de78;hp=a569c04155a05fe23e61cc8596028771332c8995;hpb=02425e05073412f9e6f18e29662be361f30464f5;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index a569c0415..a3e08ec51 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -4231,6 +4231,17 @@ static int set_option(int opt, const char *arg, const char *optname) { int ret = 0; + if (arg && arg[0] == '\0') { + /* + * This only happens if the value is read from daemon config + * file. This means the option requires an argument and the + * configuration file contains a line such as: + * my_option = + */ + ret = -EINVAL; + goto end; + } + switch (opt) { case 0: fprintf(stderr, "option %s", optname); @@ -4414,6 +4425,22 @@ static int set_option(int opt, const char *arg, const char *optname) ret = -1; } + if (ret == -EINVAL) { + const char *opt_name = "unknown"; + int i; + + for (i = 0; i < sizeof(long_options) / sizeof(struct option); + i++) { + if (opt == long_options[i].val) { + opt_name = long_options[i].name; + break; + } + } + + WARN("Invalid argument provided for option \"%s\", using default value.", + opt_name); + } +end: return ret; } @@ -5044,6 +5071,10 @@ int main(int argc, char **argv) if (is_root) { rundir = strdup(DEFAULT_LTTNG_RUNDIR); + if (!rundir) { + ret = -ENOMEM; + goto error; + } /* Create global run dir with root access */ ret = create_lttng_rundir(rundir);