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

Re: [Xen-devel] [PATCH for-4.6 1/2] libxl: fix devd removal path



On Tue, 2015-09-22 at 18:23 +0200, Roger Pau Monne wrote:
>  
> -    /* Check if event_path ends with "state" and truncate it */
> -    if (strlen(event_path) < strlen("state"))
> +    /* Check if event_path ends with "state" or "online" and truncate it. */
> +    if (strlen(event_path) < strlen("state") ||
> +        strlen(event_path) < strlen("online"))

This is the same as strlen(...) < strlen("state") (or more formaly <
min(strlen("state"),strlen("online")).

Which is a bit dangerous because one might be tricked into thinking that
path - strlen("online") was safe to do after this check when it's not. (The
new code seems to have avoided this particular pattern which the old code
used though)

I think I agree with Ian's suggestion to use strrchr.

Alternatively you could register two watches on the two specific paths you
care about and point them at wrappers which trivially strip the appropriate
trailing text and pass the base onto the current code?

BTW, what is watch_path passed to this function, is it not the watched path
i.e. the exact truncated event_path that you are looking for?

Ian.


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


 


Rackspace

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