[CRIU] [crtools-bot] fdset: Make fdset open helpers to work in all-or-nothing manner v2

Pavel Emelyanov xemul at parallels.com
Tue Jan 31 06:26:07 EST 2012


> @@ -157,15 +184,19 @@ struct cr_fdset *cr_fdset_open(int pid, unsigned long use_mask, struct cr_fdset
>  			pr_perror("Unable to open %s\n", path);
>  			goto err;
>  		}
> +		cr_fdset->fds[i] = ret;
>  
>  		pr_debug("Opened %s with %d\n", path, ret);
>  		if (write_img(ret, &fdset_template[i].magic))
>  			goto err;
> -
> -		cr_fdset->fds[i] = ret;
>  	}
> -err:
> +
>  	return cr_fdset;
> +
> +err:
> +	__close_cr_fdset(cr_fdset);
> +	xfree(cr_fdset);
> +	return NULL;

fdset  = open(NULL);

	fdset2 = open(fdset); /* fails */

close(fdset) /* crash, double free */

Do it like you planned with struct crfdset ** double pointer.

>  }


More information about the CRIU mailing list