From: Jérémie Galarneau Date: Sun, 26 Jul 2015 18:54:24 +0000 (-0400) Subject: Fix: Mishandled NULL short options in utils_generate_optstring() X-Git-Tag: v2.7.0-rc2~171 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5f1e4ef42b3f1c93bed74c74b8bd430f7d947589;p=lttng-tools.git Fix: Mishandled NULL short options in utils_generate_optstring() The NULL character is used to indicate that no short option is available for a given command. Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/utils.c b/src/common/utils.c index 4b733fb5c..766f224c7 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -1050,9 +1050,11 @@ char *utils_generate_optstring(const struct option *long_options, break; } - optstring[str_pos++] = (char)long_options[i].val; - if (long_options[i].has_arg) { - optstring[str_pos++] = ':'; + if (long_options[i].val != '\0') { + optstring[str_pos++] = (char) long_options[i].val; + if (long_options[i].has_arg) { + optstring[str_pos++] = ':'; + } } }