[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • 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
  • 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=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.