[CRIU] Off by one in mnt_get_sibling_path()

Andrew Vagin avagin at virtuozzo.com
Wed Sep 21 10:04:35 PDT 2016


On Tue, Sep 20, 2016 at 05:17:27PM +0300, Kirill Tkhai wrote:
> Hi,
> 
> int off = 0;
> 
> ...
> 
> if (p->mountpoint[1] != 0) /* not "/" */
> 	off = snprintf(path, len, "%s", p->mountpoint);
> if (path[off - 1] == '/') /* p->mountpoint = "./" */
> 
>          ^^^
> The above looks like off-by-one when off == 0. Is there is
> a condition which guarantees that off is not zero?

p->mountpoint can't be "". snprintf returns the number of characters
printed, so it should be ok
> 
> Regards,
> Kirill


More information about the CRIU mailing list