From: George Shuklin Subject: question about Xen source code (bugreport?) Date: Thu, 23 Sep 2010 21:39:18 +0400 Message-ID: <1285263558.23497.88.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org 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.