Fix: Mishandled NULL short options in utils_generate_optstring()
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 26 Jul 2015 18:54:24 +0000 (14:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 26 Jul 2015 18:54:24 +0000 (14:54 -0400)
The NULL character is used to indicate that no short option is
available for a given command.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/utils.c

index 4b733fb5cc346ead97b928809c9056eb42290904..766f224c7e167118d30dbd99c6b32595b4fe99e4 100644 (file)
@@ -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++] = ':';
+                       }
                }
        }
 
This page took 0.029617 seconds and 4 git commands to generate.