|
|
|
|
|
|
|
|
|
|
xen-changelog
[Xen-changelog] [xen-unstable] xl: fix command truncation
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1277141710 -3600
# Node ID fbef5b14f424c060a80fcb02228e87a4e7b93925
# Parent 31708477f0a92be70a940d1c8ff1aa721051bba8
xl: fix command truncation
Fix the truncation code so that it always accepts an exact match,
even when one command is a prefix of another one. This fixes,
e.g., "xl list"
Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
---
tools/libxl/xl_cmdtable.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff -r 31708477f0a9 -r fbef5b14f424 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Mon Jun 21 09:59:10 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c Mon Jun 21 18:35:10 2010 +0100
@@ -316,18 +316,19 @@ struct cmd_spec *cmdtable_lookup(const c
{
struct cmd_spec *cmd = NULL;
size_t len;
- int i;
+ int i, count = 0;
if (!s)
return NULL;
len = strlen(s);
for (i = 0; i < cmdtable_len; i++) {
if (!strncmp(s, cmd_table[i].cmd_name, len)) {
- if (cmd == NULL)
- cmd = &cmd_table[i];
- else
- return NULL;
+ cmd = &cmd_table[i];
+ /* Take an exact match, even if it also prefixes another command */
+ if (len == strlen(cmd->cmd_name))
+ return cmd;
+ count++;
}
}
- return cmd;
+ return (count == 1) ? cmd : NULL;
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-changelog] [xen-unstable] xl: fix command truncation,
Xen patchbot-unstable <=
|
|
|
|
|