From c3ecc97a9ed427183114ee041c4233661636733e Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 30 May 2017 07:40:24 +0000 Subject: [PATCH] Use memmove() instead of memcpy(), buffers are overlapping. From Coverity via NetBSD via miod@ ok claudio@, tedu@, deraadt@, krw@ --- sys/dev/hid/hidkbd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/hid/hidkbd.c b/sys/dev/hid/hidkbd.c index c517b988aed..0f4694a6498 100644 --- a/sys/dev/hid/hidkbd.c +++ b/sys/dev/hid/hidkbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hidkbd.c,v 1.4 2017/05/12 09:16:55 mpi Exp $ */ +/* $OpenBSD: hidkbd.c,v 1.5 2017/05/30 07:40:24 mpi Exp $ */ /* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -494,7 +494,7 @@ hidkbd_cngetc(struct hidkbd *kbd, u_int *type, int *data) c = kbd->sc_pollchars[0]; kbd->sc_npollchar--; - memcpy(kbd->sc_pollchars, kbd->sc_pollchars+1, + memmove(kbd->sc_pollchars, kbd->sc_pollchars+1, kbd->sc_npollchar * sizeof(u_int16_t)); *type = c & RELEASE ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN; *data = c & CODEMASK; -- 2.20.1