From cf45243ce61fb6f36c8a0ead1adb81bb4e09935c Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 16 Aug 2021 17:10:02 +0200 Subject: erts: Fix memcpy buffer overwrite It is possible for lbuf and lbuf+pos to overlap so use memmove Closes #5116 --- erts/emulator/drivers/unix/ttsl_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erts/emulator/drivers/unix/ttsl_drv.c b/erts/emulator/drivers/unix/ttsl_drv.c index d2a524cb6c..8d2fc06944 100644 --- a/erts/emulator/drivers/unix/ttsl_drv.c +++ b/erts/emulator/drivers/unix/ttsl_drv.c @@ -1105,7 +1105,7 @@ static int insert_buf(byte *s, int n) if (ch == '\n') outc('\n'); if (llen > lpos) { - memcpy(lbuf, lbuf + lpos, llen - lpos); + memmove(lbuf, lbuf + lpos, llen - lpos); } llen -= lpos; lpos = buffpos = 0; -- cgit v1.2.1