File 1255-erts-Fix-memcpy-buffer-overwrite.patch of Package erlang

From cf45243ce61fb6f36c8a0ead1adb81bb4e09935c Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Mon, 16 Aug 2021 17:10:02 +0200
Subject: [PATCH] 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
@@ -1120,7 +1120,7 @@ static int insert_buf(byte *s, int n)
                     outc('\n');
             }
 	    if (llen > lpos) {
-		memcpy(lbuf, lbuf + lpos, llen - lpos);
+		memmove(lbuf, lbuf + lpos, llen - lpos);
 	    }
 	    llen -= lpos;
 	    lpos = buffpos = 0;
-- 
2.31.1

openSUSE Build Service is sponsored by