tclpathplan.c:vgpanecmd mis-parses arguments
tclpathplan.c contains the following code:
c = argv[1][0];
size_t length = strlen(argv[1]);
…
} else if ((c == 'd') && (strncmp(argv[1], "debug", length) == 0)) {
/* debug only */
printf("debug output goes here\n");
return TCL_OK;
} else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) {
/* delete a vgpane and all memory associated with it */
At first glance, the preceding c == …
of the many branches in this code look like another strcmp
micro-optimization. However, note that any >0 prefix of "debug" will match the first branch quoted above. E.g. "de" will match this branch. I first thought this was intentional for some kind of getopt-like behavior where it accepts prefixes of valid options. But note that "de" is an ambiguous prefix (prefix of both "debug" and "delete") but will match "debug" anyway.
Is this intended? I can't see how this would lead to any behavior that makes sense to the user. My instinct is that the preceding c == …
clauses should be dropped.