Re: [LTP] [PATCH 1/3] lib: Avoid loop_info.lo_name buffer overflow
Petr Vorel <[email protected]> Tue, 28 Jul 2026 23:02:28 +0200
| Newsgroups | it.linux.lists.ltp |
|---|---|
| Message-ID | <20260728210228.GA114518@pevik> |
> 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 -- Mailing list info: https://lists.linux.it/listinfo/ltp