Re: [PATCH] mmc: use memmove to avoid strncpy on overlapping strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Hans-Christian

On Mon, 5 Nov 2018 at 16:29, Hans-Christian Noren Egtvedt
<egtvedt@xxxxxxxxxxxx> wrote:
>
> Around Mon 05 Nov 2018 08:15:50 +0100 or thereabout, Clément Péron wrote:
>
> Hello Clément,
>
> > Le dim. 4 nov. 2018 à 12:29, Hans-Christian Noren Egtvedt
> > <egtvedt@xxxxxxxxxxxx> a écrit :
> >>
> >> Using GCC 8.2.0 I see the following error.
> >>
> >> /usr/bin/gcc-8  -Wall -Werror -Wuninitialized -Wundef -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -g -O2 -Wp,-MMD,./.lsmmc.o.d,-MT,lsmmc.o -c lsmmc.c -o lsmmc.o
> >> In file included from /usr/include/string.h:494,
> >>                  from lsmmc.c:46:
> >> In function ‘strncpy’,
> >>     inlined from ‘read_file’ at lsmmc.c:356:3:
> >> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ accessing 4096 bytes at offsets 0 and 1 overlaps 4095 bytes at offset 1 [-Werror=restrict]
> >>    return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
> >>           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >> cc1: all warnings being treated as errors
> >> Makefile:36: recipe for target 'lsmmc.o' failed
> >> make: *** [lsmmc.o] Error 1
> >>
> >> Hence replace the strncpy with memmove, since using strncpy on
> >> overlapping strings is not allowed.
> >>
> >> Signed-off-by: Hans-Christian Noren Egtvedt <egtvedt@xxxxxxxxxxxx>
> >> ---
> >>  lsmmc.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/lsmmc.c b/lsmmc.c
> >> index c4faa00..7637198 100644
> >> --- a/lsmmc.c
> >> +++ b/lsmmc.c
> >> @@ -353,7 +353,7 @@ char *read_file(char *name)
> >>                 line[strlen(line) - 1] = '\0';
> >>
> >>         while (isspace(line[0]))
> >> -               strncpy(&line[0], &line[1], sizeof(line));
> >> +               memmove(&line[0], &line[1], sizeof(line) - 1);
> >
> >
> > Post the same patch a week ago : https://patchwork.kernel.org/patch/10654531/
> >
> > Could you add your review ?
>
> That looks good by me, however I could not immediate figure out how to ack a
> patch in patchwork. I even tried creating an account.

I thought you were a subscriber of the linux-mmc ML.

Patchwork is more a patch viewer/manager, you should subscribe to the
linux-mmc ML to be able to reply and add your tags.

I will add you in the next refresh,

Regards,
Clement


>
> <snipp>
>
> --
> mvh
> Hans-Christian Noren Egtvedt




[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux