On Mon, 2010-11-29 at 05:09 +0300, Pavel Vasilyev wrote:
But these are not the same. strncmp() will stop when a or b hit a null.
I'm not sure if memcmp() must do so, It may for some reason check
anything within the memory of a+c-1 or b+c-1. What happens if a or b are
right at the end of a vmalloc page, and is just a single character and
null?
x = vmalloc(32);
strcpy(x, "some 31 byte string + null");
call_func(x + 31);
in call_func we have:
call_func(char *a) {
strncmp(a, "this is some big string", 23);
With strncmp() when we hit a+1, it will stop comparing because a+1 is
null. With memcmp there's no such guarantee. We can then take a kernel
oops.
That will be a nice thing to try to debug.
Yes the above is contrived, but it demonstrates a possible problem with
this conversion.
-- Steve
--