[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180816015724.GB2793@jagdpanzerIV>
Date: Thu, 16 Aug 2018 10:57:24 +0900
From: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Minchan Kim <minchan@...nel.org>,
Peter Kalauskas <peskal@...gle.com>,
LKML <linux-kernel@...r.kernel.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
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
Powered by blists - more mailing lists