[PATCH] Fix client_add_key for minus
Simon Dawson <[email protected]> Fri, 5 Oct 2012 08:12:57 +0100
| Newsgroups | gmane.comp.sysutils.lcdproc |
|---|---|
| Message-ID | <CAHt8ZCMErCfK8eS+jEga-f873Sf1Dq0s0BXWmn5DT2pjgmT68Q@mail.gmail.com> |
Calling client_add_key as follows client_add_key - will fail. However using an explicit -shared option, like this: client_add_key -shared - will succeed. This is caused by a failure to parse the - key token, which is mistaken for the first character of an option argument. The client_add_key command also returns a spurious "success" message when a malformed option is supplied. The attached patch fixes both issues. _______________________________________________ LCDproc mailing list [email protected] http://lists.omnipotent.net/mailman/listinfo/lcdproc
lcdproc-fix-client_add_key-for-minus.patch
(application/octet-stream, 1.1 KB)
Calling client_add_key as follows client_add_key - will fail. However using an explicit -shared option, like this: client_add_key -shared - will succeed. This is caused by a failure to parse the - key token, which is mistaken for the first character of an option argument. The client_add_key command also returns a spurious "success" message when a malformed option is supplied. This patch fixes both issues. Signed-off-by: Simon Dawson <[email protected]> diff -Nurp a/server/commands/client_commands.c b/server/commands/client_commands.c --- a/server/commands/client_commands.c 2012-10-05 08:00:24.977769471 +0100 +++ b/server/commands/client_commands.c 2012-10-05 08:01:45.493765882 +0100 @@ -182,7 +182,7 @@ client_add_key_func(Client *c, int argc, } argnr = 1; - if (argv[argnr][0] == '-') { + if (argv[argnr][0] == '-' && strcmp(argv[argnr], "-") != 0) { if (strcmp( argv[argnr], "-shared") == 0) { exclusively = 0; } @@ -191,6 +191,7 @@ client_add_key_func(Client *c, int argc, } else { sock_printf_error(c->sock, "Invalid option: %s\n", argv[argnr]); + return 0; } argnr++; }