[openssh-commits] [openssh] 02/02: Add fallback for old platforms w/out MAP_ANON.

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Nov 23 13:27:59 AEDT 2022


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit 15a01cf15f396f87c6d221c5a6af98331c818962
Author: Darren Tucker <dtucker at dtucker.net>
Date:   Wed Nov 23 13:18:54 2022 +1100

    Add fallback for old platforms w/out MAP_ANON.
---
 openbsd-compat/arc4random.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/openbsd-compat/arc4random.h b/openbsd-compat/arc4random.h
index 2b57611f..01629752 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)
 {
+#if defined(MAP_ANON) && defined(MAP_PRIVATE)
 	if ((*rsp = mmap(NULL, sizeof(**rsp), PROT_READ|PROT_WRITE,
 	    MAP_ANON|MAP_PRIVATE, -1, 0)) == MAP_FAILED)
 		return (-1);
@@ -73,6 +74,15 @@ _rs_allocate(struct _rs **rsp, struct _rsx **rsxp)
 		*rsp = NULL;
 		return (-1);
 	}
+#else
+	if ((*rsp = malloc(sizeof(**rsp))) == NULL)
+		return (-1);
+	if ((*rsxp = malloc(sizeof(**rsxp))) == NULL) {
+		free(*rsp);
+		*rsp = NULL;
+		return (-1);
+	}
+#endif
 
 	_ARC4_ATFORK(_rs_forkhandler);
 	return (0);

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list