From 5b50ebaefb128f2ecc0921e7009d6b54b96a7633 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Thu, 13 Jun 2019 15:05:18 +0100 Subject: [PATCH] libdockapp: removed assertion that short-form options have length 2. The mixed-option parsing code includes an assertion that short-form options have a length of two. However, there is no other validation of this requirement and some dock-apps do not comply with it, which means that if one exec's them with an unrecognized option or a mix of short options, the assertion fails and the app aborts. For example: $ /usr/bin/wmail --help | grep '\' -display display to use $ /usr/bin/wmail --blah wmail: daargs.c:126: contains: Assertion `strlen(needle) == 2' failed. Aborted Since there is no explicit statement of this requirement, let's replace the assertion with a conditional. --- libdockapp/src/daargs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libdockapp/src/daargs.c b/libdockapp/src/daargs.c index eab61cc..99a8f73 100644 --- a/libdockapp/src/daargs.c +++ b/libdockapp/src/daargs.c @@ -117,13 +117,11 @@ DAParseArguments( int contains(char *needle, char *haystack) { - char c, *pos; + char *pos = NULL; - assert(strlen(needle) == 2); - - c = needle[1]; - - pos = strchr(haystack, c); + if (strlen(needle) == 2 && needle[0] == '-') { + pos = strchr(haystack, needle[1]); + } return (pos != NULL); }