new MKSH_A4PB cppflag: force use of arc4random_pushb(3) during seeding

just the way sysctl KERN_ARND currently is used on OpenBSD/MirBSD (for
manual packager overrides only, no mirtoconf check; e.g. for Cygwin)
This commit is contained in:
tg 2010-07-18 17:29:50 +00:00
parent 7c91e018f4
commit f10186fedd
2 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.454 2010/07/04 17:45:10 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.455 2010/07/18 17:29:49 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# Thorsten Glaser <tg@mirbsd.org>
@ -29,7 +29,7 @@ srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.454 2010/07/04 17:45:10 tg Exp $'
# MKSH_CONSERVATIVE_FDS MKSH_MIDNIGHTBSD01ASH_COMPAT
# MKSH_NOPWNAM MKSH_NO_LIMITS MKSH_SMALL MKSH_S_NOVI
# MKSH_UNEMPLOYED MKSH_DEFAULT_EXECSHELL MKSHRC_PATH
# MKSH_DEFAULT_TMPDIR MKSH_CLRTOEOL_STRING
# MKSH_DEFAULT_TMPDIR MKSH_CLRTOEOL_STRING MKSH_A4PB
LC_ALL=C
export LC_ALL

12
var.c
View File

@ -26,7 +26,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.108 2010/07/17 22:09:40 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.109 2010/07/18 17:29:50 tg Exp $");
/*
* Variables
@ -1050,6 +1050,16 @@ change_random(const void *vp, size_t n)
/* we ignore failures and take in k anyway */
h = oaathash_update(h, k, sizeof(k));
kshstate_v.lcg_state_ = oaathash_finalise(h);
#elif defined(MKSH_A4PB)
/* forced by the user to use arc4random_pushb(3) • Cygwin? */
{
uint32_t prv;
prv = arc4random_pushb(&kshstate_v.lcg_state_,
sizeof(kshstate_v.lcg_state_));
h = oaathash_update(h, &prv, sizeof(prv));
}
kshstate_v.lcg_state_ = oaathash_finalise(h);
#endif
}