{
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;
- }
-
if (string_match(optname, "client-sock") || opt == 'c') {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"-c, --client-sock");
snprintf(client_unix_sock_path, PATH_MAX, "%s", arg);
}
} else if (string_match(optname, "apps-sock") || opt == 'a') {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"-a, --apps-sock");
} else if (string_match(optname, "background") || opt == 'b') {
opt_background = 1;
} else if (string_match(optname, "group") || opt == 'g') {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"-g, --group");
} else if (string_match(optname, "sig-parent") || opt == 'S') {
opt_sig_parent = 1;
} else if (string_match(optname, "kconsumerd-err-sock")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--kconsumerd-err-sock");
snprintf(kconsumer_data.err_unix_sock_path, PATH_MAX, "%s", arg);
}
} else if (string_match(optname, "kconsumerd-cmd-sock")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--kconsumerd-cmd-sock");
snprintf(kconsumer_data.cmd_unix_sock_path, PATH_MAX, "%s", arg);
}
} else if (string_match(optname, "ustconsumerd64-err-sock")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--ustconsumerd64-err-sock");
snprintf(ustconsumer64_data.err_unix_sock_path, PATH_MAX, "%s", arg);
}
} else if (string_match(optname, "ustconsumerd64-cmd-sock")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--ustconsumerd64-cmd-sock");
snprintf(ustconsumer64_data.cmd_unix_sock_path, PATH_MAX, "%s", arg);
}
} else if (string_match(optname, "ustconsumerd32-err-sock")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--ustconsumerd32-err-sock");
snprintf(ustconsumer32_data.err_unix_sock_path, PATH_MAX, "%s", arg);
}
} else if (string_match(optname, "ustconsumerd32-cmd-sock")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--ustconsumerd32-cmd-sock");
opt_verbose_consumer += 1;
}
} else if (string_match(optname, "consumerd32-path")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--consumerd32-path");
consumerd32_bin_override = 1;
}
} else if (string_match(optname, "consumerd32-libdir")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--consumerd32-libdir");
consumerd32_libdir_override = 1;
}
} else if (string_match(optname, "consumerd64-path")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--consumerd64-path");
consumerd64_bin_override = 1;
}
} else if (string_match(optname, "consumerd64-libdir")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--consumerd64-libdir");
consumerd64_libdir_override = 1;
}
} else if (string_match(optname, "pidfile") || opt == 'p') {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"-p, --pidfile");
}
}
} else if (string_match(optname, "agent-tcp-port")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--agent-tcp-port");
DBG3("Agent TCP port set to non default: %u", agent_tcp_port);
}
} else if (string_match(optname, "load") || opt == 'l') {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"-l, --load");
}
}
} else if (string_match(optname, "kmod-probes")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--kmod-probes");
}
}
} else if (string_match(optname, "extra-kmod-probes")) {
+ if (!arg || *arg == '\0') {
+ ret = -EINVAL;
+ goto end;
+ }
if (lttng_is_setuid_setgid()) {
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"--extra-kmod-probes");