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

Andrea Cervesato andrea.cervesato@suse.com
Tue Jul 28 16:19:24 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.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com


More information about the ltp mailing list