kumquat-buildroot/package/screen/0001-Do-not-use-memcpy-as-an-alternative-for-bcopy-memmov.patch
Julien Olivain 96a54b0907 package/screen: security bump to version 4.9.1
See release announce:
https://lists.gnu.org/archive/html/screen-users/2023-08/msg00000.html

Fixes:
CVE-2023-24626: https://www.cve.org/CVERecord?id=CVE-2023-24626

Note: Buildroot installs screen as setuid, so the described scenario
in CVE applies.

This commit also rebases all patches on this release. Patch were
regenerated with 'git format-patch -N', so patch file name changed in
this process. The file .checkpackageignore is also updated accordingly.

Signed-off-by: Julien Olivain <ju.o@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-08-24 22:34:41 +02:00

134 lines
3.6 KiB
Diff

From 545875ad0b6c9697fae41ae8770e95d117fe3cca Mon Sep 17 00:00:00 2001
From: Maarten ter Huurne <maarten@treewalker.org>
Date: Sat, 13 Sep 2014 11:37:59 +0200
Subject: [PATCH] Do not use memcpy as an alternative for bcopy/memmove
The configure script runs a small test program to check whether
memcpy can handle overlapping memory areas. However, it is not valid
to conclude that if a single case of overlapping memory is handled
correctly, all cases will be handled correctly.
Since screen already has its own bcopy implementation as a fallback
for the case that bcopy and memmove are unusable, removing the memcpy
option should not break any systems.
Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
[Ricardo: rebase on top of 4.3.1]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
[Bernd: rebase on top of 4.7.0]
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
[Julien: rebase on top of 4.9.1]
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
acconfig.h | 3 +--
configure.ac | 22 +---------------------
os.h | 8 ++------
osdef.h.in | 10 +---------
4 files changed, 5 insertions(+), 38 deletions(-)
diff --git a/acconfig.h b/acconfig.h
index 46d62b0..f83572c 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -476,7 +476,7 @@
#undef GETTTYENT
/*
- * Define USEBCOPY if the bcopy/memcpy from your system's C library
+ * Define USEBCOPY if the bcopy from your system's C library
* supports the overlapping of source and destination blocks. When
* undefined, screen uses its own (probably slower) version of bcopy().
*
@@ -487,7 +487,6 @@
* Their memove fails the test in the configure script. Sigh. (Juergen)
*/
#undef USEBCOPY
-#undef USEMEMCPY
#undef USEMEMMOVE
/*
diff --git a/configure.ac b/configure.ac
index 1a12c04..6f6c2da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1278,7 +1278,7 @@ AC_TRY_LINK([
fdwalk(NULL, NULL);
],AC_DEFINE(HAVE_FDWALK))
-AC_CHECKING(whether memcpy/memmove/bcopy handles overlapping arguments)
+AC_CHECKING(whether memmove/bcopy handles overlapping arguments)
AC_TRY_RUN([
#include <string.h>
#include <stdlib.h>
@@ -1319,26 +1319,6 @@ main() {
}], AC_DEFINE(USEMEMMOVE),,
AC_NOTE(- skipping check because we are cross compiling; use memmove) AC_DEFINE(USEMEMMOVE))
-AC_TRY_RUN([
-#include <string.h>
-#include <stdlib.h>
-
-#define bcopy(s,d,l) memcpy(d,s,l)
-
-int
-main() {
- char buf[10];
- strcpy(buf, "abcdefghi");
- bcopy(buf, buf + 2, 3);
- if (strncmp(buf, "ababcf", 6))
- return 1;
- strcpy(buf, "abcdefghi");
- bcopy(buf + 2, buf, 3);
- if (strncmp(buf, "cdedef", 6))
- return 1;
- return 0; /* libc version works properly. */
-}], AC_DEFINE(USEMEMCPY),,:)
-
AC_SYS_LONG_FILE_NAMES
AC_MSG_CHECKING(for vsprintf)
diff --git a/os.h b/os.h
index 2a1c2ca..d1ac87e 100644
--- a/os.h
+++ b/os.h
@@ -142,12 +142,8 @@ extern int errno;
# ifdef USEMEMMOVE
# define bcopy(s,d,len) memmove(d,s,len)
# else
-# ifdef USEMEMCPY
-# define bcopy(s,d,len) memcpy(d,s,len)
-# else
-# define NEED_OWN_BCOPY
-# define bcopy xbcopy
-# endif
+# define NEED_OWN_BCOPY
+# define bcopy xbcopy
# endif
#endif
diff --git a/osdef.h.in b/osdef.h.in
index 6ddbd66..abdacf7 100644
--- a/osdef.h.in
+++ b/osdef.h.in
@@ -58,16 +58,8 @@ extern int bcmp __P((char *, char *, int));
extern int killpg __P((int, int));
#endif
-#ifndef USEBCOPY
-# ifdef USEMEMCPY
-extern void memcpy __P((char *, char *, int));
-# else
-# ifdef USEMEMMOVE
+#if defined(USEMEMMOVE) && !defined(USEBCOPY)
extern void memmove __P((char *, char *, int));
-# else
-extern void bcopy __P((char *, char *, int));
-# endif
-# endif
#else
extern void bcopy __P((char *, char *, int));
#endif
--
2.41.0