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

[Xen-devel] question about Xen source code (bugreport?)


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: George Shuklin <george.shuklin@xxxxxxxxx>
  • Date: Thu, 23 Sep 2010 21:39:18 +0400
  • Delivery-date: Thu, 23 Sep 2010 10:40:38 -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 :content-transfer-encoding; b=tNLMT2mwSN3SVH0zHjECOqIFVU/6zPEF+ebM1EsEuKNpM/frKyPii/Zp+r5Cnlg05i 0veCdIbSic9Z2c3BhGgyWijgoOnqErbqZYOs9U3VbJdDYh4V7aqdVtCp3vUZtnjdPVNM cV5bV+kTJj2rLuhOibdwIBvoRJ+MDRKV5E8vc=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

Good day. 

I digging to Xen sources and found some kind of bug...

xen-3.4.2/tools/blktap ,function:

int convert_dev_name_to_num(char *name) 

It use some extremely strange expressions I could not understand.


           for(i = 0, ptr = alpha; i < strlen(alpha); i++) {
                        if(*ptr == *p) break;
                        *ptr++;
                }
                *p++;


What meaning of *p++? Why not simply p++?

And few lines lower:

ret = (202*256) + (16*i) + atoi(p);   (focus on atoi(p))

But atoi() behaviour is undefined if argument contains not number, but
letters.

Cite from Open Group POSIX specification: If the value cannot be
represented, the behavior is undefined:
http://www.opengroup.org/onlinepubs/000095399/functions/atoi.html


And I can create device /dev/xvdaa or something like this (I use XCP, so
it is command like: xe vbd-create ... device=999).

And this code become simply 'undefined behaviour. It can crash, do 'rm
-rf /' or simply return wrong value.

---
wBR, George.




_______________________________________________
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®.