lkml.org 
[lkml]   [2018]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2018-08-16 03:58    [W:0.065 / U:1.504 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site