On Sun, Jan 30, 2022 at 01:00:21PM -0500, Mark Mielke wrote: > Sorry, I knee jerk react to "partial match", which was a red flag for > me, so strncmp() is almost never used for "partial match" in my > experience. :-) > > It's really that strncmp() should be used for buffer overflow > protection, but in this case - it's not. Since, the ", 5" applies to > the clearly visible "=All" that is both allocated and '\0' terminated. > It should be against the remaining buffer size of text_ptr. So, > removing the ", 5" leaves it equally as bad at buffer overflow > protection as it was before. :-) This isn't really about my patch we all agree leaves things "as it was before". In this case, strncmp() was just copy and paste from the surrounding code and not used as an overflow check. What you're describing does exist but it's about 1% of use cases. There are about 2868 calls to strncmp() in the kernel. In my x86 allmodconfig only about 18 of them use strncmp() for buffer overflow checking. Then there are some real puzzlers which do: if (strncmp(variable, "foo", sizeof("foo")) == 0) { regards, dan carpenter