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] libxl: fix cd insert/eject

To: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] libxl: fix cd insert/eject
From: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Date: Thu, 17 Feb 2011 19:10:59 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 17 Feb 2011 11:11:36 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <alpine.DEB.2.00.1102171535480.2826@kaball-desktop>
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Newsgroups: chiark.mail.xen.devel
References: <alpine.DEB.2.00.1102171535480.2826@kaball-desktop>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Stefano Stabellini writes ("[Xen-devel] [PATCH] libxl: fix cd insert/eject"):
> +    char backend_type[5];
...
> +    sscanf(backend, "/local/domain/%d/backend/%5[a-z]/%*d/%*d", 
> &disk->backend_domid, backend_type);

>From sscanf(3):

       s      Matches  a  sequence  of  non-white-space  characters;  the next
              pointer must be a pointer to character array that is long enough
              to  hold  the  input sequence and the terminating null character
              ('\0'), which is added automatically.  The input string stops at
              white  space  or  at  the  maximum field width, whichever occurs
              first.

So I think your buffer has an off-by-one error in its size.

Also you should not duplicate a magic number like that.  Use a #define
and preprocessor stringification.

Ian.

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

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