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-devel

Re: [Xen-devel] [PATCH 1/2] Make shutdown use strings instead of codes

To: Dan Smith <danms@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 1/2] Make shutdown use strings instead of codes
From: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Date: Sat, 06 Aug 2005 18:17:53 +1000
Cc: "List: Xen Developers" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Sat, 06 Aug 2005 08:16:49 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <m3hde4xljt.fsf@xxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <m3hde4xljt.fsf@xxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Fri, 2005-08-05 at 11:53 -0700, Dan Smith wrote:
> This patch changes the shutdown driver and xend to use strings instead
> of codes for signaling a shutdown request.

Commenting on this:

+    unsigned int len;
+
+    str = (char *)xenbus_read("control", "shutdown", &len);
+
+    if (! len) {
         return;
-    };
+    }

xenbus_read will always nul-terminate the string it receives, and you
should *never* test len as an indication of error!

It should be:
        str = xenbus_read("control", "shutdown", NULL);
        if (IS_ERR(str))
                return;

Cheers!
Rusty.
-- 
A bad analogy is like a leaky screwdriver -- Richard Braakman


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>