[LTP] [PATCH v7 1/3] lib: alter find_free_loopdev()

Cyril Hrubis chrubis@suse.cz
Wed Jul 31 14:28:54 CEST 2019


Hi!
> ...
> > +++ b/lib/tst_device.c
> ...
> > -			return 0;
> > +			if (path != NULL)
> > +				strncpy(path, buf, path_len);
> Is it safe to assume that path_len is *always* < 1024 (size of buf)?

strncpy() is tricky that it may not null-terminate the string if the
source is too long, I would have just added path[path_len-1] = 0 after
the strncpy() here.

> > +			return i;
> ...
> 
> 
> Kind regards,
> Petr

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list