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

Re: [Xen-devel] [RFC PATCH] tools/libxl : add struct and parsing utils for the 'static_shm' xl config entry



On Thu, 20 Jul 2017, Zhongze Liu wrote:
> >>> +    } else if (!strcmp(key, "begin") || !strcmp(key, "end")) {
> >>> +        char *endptr;
> >>> +        int base = 10;
> >>> +        uint64_t new_bound;
> >>> +
> >>> +        /* could be in hex form */
> >>> +        if ('0' == val[0] && 'x' == val[1]) { base = 16; }
> >>
> >> Shouldn't you check that val is at least 2 in length?
> >
> > Yes. Sorry. I will fix this.
> 
> When I tried to add some length checking here I recalled that I have
> thought about this problem already and this isn't going to cause troubles.
> Because I've already made both key and val NULL-terminated strings.
> If the length is 0, val[0] will be '0' and the && will be short-circuit'ed.
> If the length is 1, the second check will fail because val[1] will be '0'.

OK. It might be worth adding an in-code comment about it.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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