[CRIU] [PATCH 8/9] check_path_remap(): fix error checks

Tycho Andersen tycho.andersen at canonical.com
Wed Oct 7 05:12:14 PDT 2015


On Wed, Oct 07, 2015 at 02:44:23AM -0700, Kir Kolyshkin wrote:
> Naturally, checking strstr()+1 for NULL is useless.
> 
> Reported by Coverity, CID 51594.
> 
> Signed-off-by: Kir Kolyshkin <kir at openvz.org>
> ---
>  files-reg.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/files-reg.c b/files-reg.c
> index f07da31..59d88ca 100644
> --- a/files-reg.c
> +++ b/files-reg.c
> @@ -809,13 +809,13 @@ static int check_path_remap(struct fd_link *link, const struct fd_parms *parms,
>  		char *start, *end;
>  
>  		/* skip "./proc/" */
> -		start = strstr(rpath, "/") + 1;
> +		start = strstr(rpath, "/");
>  		if (!start)
>  			return -1;
> -		start = strstr(start, "/") + 1;
> +		start = strstr(start + 1, "/");
>  		if (!start)
>  			return -1;
> -		pid = strtol(start, &end, 10);
> +		pid = strtol(start + 1, &end, 10);

Whoops.

Acked-by: Tycho Andersen <tycho.andersen at canonical.com>

>  		/* if we didn't find another /, this path something
>  		 * like ./proc/kmsg, which we shouldn't mess with. */
> -- 
> 2.4.3
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list