WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xl: fix command truncation

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: fix command truncation
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 21 Jun 2010 10:45:35 -0700
Delivery-date: Mon, 21 Jun 2010 10:49:42 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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 <=