George Shuklin
2010-Sep-23 21:03 UTC
[Xen-devel] [patch] Bugfix for tools/blktap/lib/xs_api.c (convert_dev_name_to_num)
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. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Jackson
2010-Sep-24 15:30 UTC
Re: [Xen-devel] [patch] Bugfix for tools/blktap/lib/xs_api.c (convert_dev_name_to_num)
George Shuklin writes ("[Xen-devel] [patch] Bugfix for tools/blktap/lib/xs_api.c (convert_dev_name_to_num)"):> I rewrote function convert_dev_name_to_num from > tools/blktap/lib/xs_api.cThanks but I''m afraid I don''t think your patch is either a good idea or suitable. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
George Shuklin
2010-Sep-24 17:43 UTC
Re: [Xen-devel] [patch] Bugfix for tools/blktap/lib/xs_api.c (convert_dev_name_to_num)
Well, I do not insist, but could you explain reason of using construction like *p++; or using atoi to arbitrary string? В Птн, 24/09/2010 в 16:30 +0100, Ian Jackson пишет:> George Shuklin writes ("[Xen-devel] [patch] Bugfix for tools/blktap/lib/xs_api.c (convert_dev_name_to_num)"): > > I rewrote function convert_dev_name_to_num from > > tools/blktap/lib/xs_api.c > > Thanks but I''m afraid I don''t think your patch is either a good idea > or suitable. > > Ian._______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel