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@lists.xen.org
https://lists.xen.org/xen-devel

Reply via email to