Messages in this thread | | | Date | Thu, 16 Aug 2018 10:57:24 +0900 | From | Sergey Senozhatsky <> | Subject | Re: [PATCH] zram: fix bug storing backing_dev |
| |
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
| |