Re: [PATCH] zram: fix bug storing backing_dev

Sergey Senozhatsky
2018-08-16T01:57:32Z

A bunch of corrections

On (08/16/18 10:48), Sergey Senozhatsky wrote:
> The problem is that strlcpy() copies as many bytes as the source string
> has, not as many bytes as destination string can fit.

I mean - strlcpy() expects that the 3rd argument will be sizeof(dst), but
we passed the wrong argument strlen(src), so we used strlcpy() like
if it was strncpy(). The difference between strncpy() and strlcpy() is in
the 3rd argument.

> IOW:
>
> char dst[100];
> char src[1000];
> ...
> strlcpy(dst, src, strlen(src));
>
> where it should do
>
> strlcpy(dst, src, strlen(dst));

^^^ sizeof()

> A side note,
> There is sysfs_strcmp(), which takes care of that "user space may append

^^^ sysfs_streq()

-ss