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

[Xen-devel] [patch] Bugfix for tools/blktap/lib/xs_api.c (convert_dev_na

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [patch] Bugfix for tools/blktap/lib/xs_api.c (convert_dev_name_to_num)
From: George Shuklin <george.shuklin@xxxxxxxxx>
Date: Fri, 24 Sep 2010 01:03:16 +0400
Delivery-date: Thu, 23 Sep 2010 14:05:36 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:content-type :date:message-id:mime-version:x-mailer; bh=k1quOZorQQdQXqzwdK0/PJvS3V/zjEZ81pbi5pAYioc=; b=EbQphvYX5e7Z/QGRmNck3nE1DeYoqjSY6TxcqejYCqV58v9Wl1reDgTA+3mMcxd5k4 Ng7X1HduAlpAKWE/X6QTxHKe3vGXz05JVvKGuEu4s6NnsU+cRiRThLKqWdIM5AhhLx31 wEJYwbgn3ZK2c4zmCAGwjjTpUkY5dt0g5kkkQ=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:content-type:date:message-id:mime-version:x-mailer; b=GtCtxiMw9SakYFeamgmMKtFWy750CVklKQuTJcvT9Ng/cx/vINpBz9hhQuVng0Wma1 k6/fJ6JEnQTq+IxLeJfoEYV5sNhvGT0o3WXY9XUyu6hL9W+YdCwCW/ab3n/6Ajj8GkzK hZljuYq0hmCopGlmNSIWtBDj2TcZEKH5k5eZU=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
I rewrote function convert_dev_name_to_num from
tools/blktap/lib/xs_api.c

Difference:

All code in loops has been converted from ..perverted for+while code to
pure for. sizeof for char[]="..." will works faster, than
strlen(string), strange *pte++ have been removed, *p++ changed to p+1 in
function calls.

Second change more disputable: I change code:

ret = (majors[i/2]*256) + atoi(p);

to 

ret = (majors[i/2]*256) + isdigit(p[1]) ? atoi(p) : 0;

I believe it will clear out undefined behavior to atoi when it called
with non-convertible value (like letter or \x0).

I have not access to commits to hg, so diff in attachment for freshest
xen-unstable.hg.

I think this patch can be apply to xen 3.4 too, where I found this bug
early.

---
wBR, George.

Attachment: xs_api-convert_dev_names_to_num_cleanup.diff
Description: Text Data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>