1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
BASH PATCH REPORT
=================
Bash-Release: 5.3
Patch-ID: bash53-002
Bug-Reported-by:
Bug-Reference-ID:
Bug-Reference-URL: https://savannah.gnu.org/bugs/?67326
Bug-Description:
There are too many differences in the various implementations of shm_open(2)
to rely on it for bash's use.
--- a/lib/sh/anonfile.c
+++ b/lib/sh/anonfile.c
@@ -25,7 +25,7 @@
#endif
#include <bashtypes.h>
-#if defined (HAVE_MEMFD_CREATE) || defined (HAVE_SHM_OPEN) || defined (HAVE_SHM_MKSTEMP)
+#if defined (HAVE_MEMFD_CREATE) || defined (HAVE_SHM_MKSTEMP)
# include <sys/mman.h>
#endif
#include <filecntl.h>
@@ -41,17 +41,7 @@ static int anonunlink (const char *);
# define MFD_NOEXEC_SEAL 0
#endif
-#if defined (HAVE_SHM_OPEN)
-#ifndef O_NOFOLLOW
-# define O_NOFOLLOW 0
-#endif
-
-static int
-anonshmunlink (const char *fn)
-{
- return (shm_unlink (fn));
-}
-
+#if defined (HAVE_SHM_MKSTEMP)
static int
anonshmopen (const char *name, int flags, char **fn)
{
@@ -62,35 +52,14 @@ anonshmopen (const char *name, int flags
if (fn)
*fn = 0;
-#if defined (HAVE_SHM_MKSTEMP)
fname = savestring ("/shm-XXXXXXXXXX");
fd = shm_mkstemp (fname);
if (fd < 0)
- free (fname);
-#endif
-
- if (fd < 0)
- {
- fname = sh_mktmpname (name, flags);
- fd = shm_open (fname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600);
- }
-
- if (fd < 0)
{
free (fname);
return fd;
}
- if (shm_unlink (fname) < 0)
- {
- int o;
- o = errno;
- free (fname);
- close (fd);
- errno = o;
- return -1;
- }
-
if (fn)
*fn = fname;
else
@@ -122,7 +91,7 @@ anonopen (const char *name, int flags, c
/* Heuristic */
flag = (name && *name == '/') ? MT_TEMPLATE : MT_USETMPDIR;
-#if defined (HAVE_SHM_OPEN)
+#if defined (HAVE_SHM_MKSTEMP)
fd = anonshmopen (name, flag, fn);
if (fd >= 0)
return fd; /* anonshmopen sets *FN appropriately */
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
-#define PATCHLEVEL 1
+#define PATCHLEVEL 2
#endif /* _PATCHLEVEL_H_ */
|