Message ID | 1405428862-23307-1-git-send-email-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On Tue, Jul 15, 2014 at 8:54 PM, Colin King <colin.king@canonical.com> wrote: > From: Colin Ian King <colin.king@canonical.com> > > better to use memmove rather than strcpy; Coverity Scan reports > that there is a potential overlap with the underlying memory copy > so use memmove which has the smarts to do this correctly. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/utilities/kernelscan.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c > index 1b793bb..78c70d5 100644 > --- a/src/utilities/kernelscan.c > +++ b/src/utilities/kernelscan.c > @@ -741,7 +741,7 @@ static void literal_strip_quotes(token *t) > > t->token[len-1] = 0; > > - strcpy(t->token, t->token + 1); > + memmove(t->token, t->token + 1, len - 1); > } > > /* > -- > 2.0.1 > > Acked-by: Keng-Yu Lin <kengyu@canonical.com>
On 07/15/2014 08:54 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > better to use memmove rather than strcpy; Coverity Scan reports > that there is a potential overlap with the underlying memory copy > so use memmove which has the smarts to do this correctly. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/utilities/kernelscan.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c > index 1b793bb..78c70d5 100644 > --- a/src/utilities/kernelscan.c > +++ b/src/utilities/kernelscan.c > @@ -741,7 +741,7 @@ static void literal_strip_quotes(token *t) > > t->token[len-1] = 0; > > - strcpy(t->token, t->token + 1); > + memmove(t->token, t->token + 1, len - 1); > } > > /* > Acked-by: Alex Hung <alex.hung@canonical.com>
diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c index 1b793bb..78c70d5 100644 --- a/src/utilities/kernelscan.c +++ b/src/utilities/kernelscan.c @@ -741,7 +741,7 @@ static void literal_strip_quotes(token *t) t->token[len-1] = 0; - strcpy(t->token, t->token + 1); + memmove(t->token, t->token + 1, len - 1); } /*