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] question about Xen source code (bugreport?)

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] question about Xen source code (bugreport?)
From: George Shuklin <george.shuklin@xxxxxxxxx>
Date: Thu, 23 Sep 2010 21:06:04 +0400
Delivery-date: Thu, 23 Sep 2010 10:07:44 -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:content-transfer-encoding; bh=q4BWpMWC9E824G6UJzyePmujTh4Fx1VppaotQPhJjW0=; b=mkamzEyYYZA6/KZVy1i0uMh9DkE+oqTeCr8XzMD0vqiWEsQmhXlKgGu7GZmIh7jBAV 6Pi1/UQhRbNHbe7dS40Tr8gVo5r8kFSqH9T4DcqCkKrpu08hNzCwwpOljkI/cCwK//wS mLBMiNwu6EKKRC+LKLii4hnScf16U2Xc56i8k=
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=rfd0e9jtEj1wfG74LRBKg/5iWnIDmAIlaBhu1ToBDJzSTZxH7lXnsDjj1itiuYrF4b xXvOMQCPZyGUnAVNHP+OnbA0LvjYiAe8IMa4GgEFZ9fDSltvqfHzQaC7mNFjRJxcocth D3fr9vy19185osdWxJpXUoOb2qtAvbSzn/KoE=
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
Good day. 

I looked to xen-3.4.2/tools/blktap source code and found function 

int convert_dev_name_to_num(char *name) 

It use some extremely strange expression 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

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