[LTP] [PATCH 1/3] lib: Avoid loop_info.lo_name buffer overflow

Petr Vorel pvorel@suse.cz
Tue Jul 28 23:02:28 CEST 2026


> Hi Petr,

> > I suppose strncpy() is recommended as safer alternative to strcpy(),
> > right? Shouldn't we check for strlen(file) is not longer than
> > sizeof(loopinfo.lo_name) -1 while we are at it?

> we don't need to check for strlen(file) because strncpy() copy
> min(strlen(loopinfo.lo_name), strlen(file)) chars at max.

I mean if file is longer, then only part will be copied and following ioctl()
will fail, right? Therefore warning about too long name would help.

Kind regards,
Petr


More information about the ltp mailing list