openssh: update 9.1p1
This commit is contained in:
54
openssh/src/0001-Workaround-missing-MAP_ANON.patch
Normal file
54
openssh/src/0001-Workaround-missing-MAP_ANON.patch
Normal file
@@ -0,0 +1,54 @@
|
||||
From 2117a08838a57b2d042cc7df7010ff6a863613f6 Mon Sep 17 00:00:00 2001
|
||||
From: "Tom G. Christensen" <tgc@jupiterrise.com>
|
||||
Date: Sun, 16 Oct 2022 18:29:07 +0200
|
||||
Subject: [PATCH] Workaround missing MAP_ANON
|
||||
|
||||
On Solaris MAP_ANON is only available from Solaris 8 and onward so a
|
||||
workaround is needed.
|
||||
This patch is based on https://stackoverflow.com/a/39945292
|
||||
---
|
||||
openbsd-compat/arc4random.h | 21 +++++++++++++++++++++
|
||||
1 file changed, 21 insertions(+)
|
||||
|
||||
diff --git a/openbsd-compat/arc4random.h b/openbsd-compat/arc4random.h
|
||||
index 2b57611f..a7cbe1c4 100644
|
||||
--- a/openbsd-compat/arc4random.h
|
||||
+++ b/openbsd-compat/arc4random.h
|
||||
@@ -63,6 +63,7 @@ _rs_forkdetect(void)
|
||||
static inline int
|
||||
_rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
|
||||
{
|
||||
+#ifdef MAP_ANON
|
||||
if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE,
|
||||
MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
|
||||
return (-1);
|
||||
@@ -73,6 +74,26 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
|
||||
*rsp = NULL;
|
||||
return (-1);
|
||||
}
|
||||
+#else /*Map /dev/zero*/
|
||||
+ int fd;
|
||||
+ fd = open("/dev/zero", O_RDWR);
|
||||
+ if (fd == -1)
|
||||
+ return (-1);
|
||||
+
|
||||
+ if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE,
|
||||
+ MAP_PRIVATE, fd, 0)) == MAP_FAILED)
|
||||
+ return (-1);
|
||||
+
|
||||
+ if ((*rsxp = mmap(NULL, sizeof(**rsxp), PROT_READ|PROT_WRITE,
|
||||
+ MAP_PRIVATE, fd, 0)) == MAP_FAILED) {
|
||||
+ munmap(*rsp, sizeof(**rsp));
|
||||
+ *rsp = NULL;
|
||||
+ return (-1);
|
||||
+ }
|
||||
+
|
||||
+ if (close(fd) == -1) /*No longer needed*/
|
||||
+ return (-1);
|
||||
+#endif
|
||||
|
||||
_ARC4_ATFORK(_rs_forkhandler);
|
||||
return (0);
|
||||
--
|
||||
2.36.1
|
||||
|
||||
Reference in New Issue
Block a user