• better IV for the oaathash-on-binary (as if we prepended a '\x01')

• better variable name for the LCG state
This commit is contained in:
tg 2009-10-18 12:30:06 +00:00
parent eafe88aa74
commit ceb591bf6a
3 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.333 2009/10/17 21:16:01 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.334 2009/10/18 12:30:04 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R39 2009/10/17
@(#)MIRBSD KSH R39 2009/10/18
description:
Check version of shell.
stdin:

4
sh.h
View File

@ -134,9 +134,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.356 2009/10/17 21:16:04 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.357 2009/10/18 12:30:05 tg Exp $");
#endif
#define MKSH_VERSION "R39 2009/10/17"
#define MKSH_VERSION "R39 2009/10/18"
#ifndef MKSH_INCLUDES_ONLY

16
var.c
View File

@ -22,7 +22,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.95 2009/10/17 21:16:05 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.96 2009/10/18 12:30:06 tg Exp $");
/*
* Variables
@ -50,7 +50,7 @@ static const char *array_index_calc(const char *, bool *, uint32_t *);
static uint32_t oaathash_update(register uint32_t, register const uint8_t *,
register size_t);
static uint32_t lcg_seed = 5381;
static uint32_t lcg_state = 5381;
#endif
uint8_t set_refflag = 0;
@ -989,7 +989,7 @@ oaathash_update(register uint32_t h, register const uint8_t *cp,
void
change_random(const void *vp, size_t n)
{
register uint32_t h;
register uint32_t h = 0x100;
struct {
const void *sp, *bp, *dp;
size_t dsz;
@ -999,18 +999,18 @@ change_random(const void *vp, size_t n)
i.dp = vp;
i.dsz = n;
i.s = lcg_seed;
i.bp = &lcg_seed;
i.s = lcg_state;
i.bp = &lcg_state;
i.sp = &i;
gettimeofday(&i.tv, NULL);
h = oaathash_update(oaathash_update(1, (void *)&i, sizeof(i)), vp, n);
h = oaathash_update(oaathash_update(h, (void *)&i, sizeof(i)), vp, n);
/* oaathash_finalise */
h += h << 3;
h ^= h >> 11;
h += h << 15;
lcg_seed = h;
lcg_state = h;
}
#endif
@ -1071,7 +1071,7 @@ getspec(struct tbl *vp)
* this is the same Linear Congruential PRNG as Borland
* C/C++ allegedly uses in its built-in rand() function
*/
i = ((lcg_seed = 22695477 * lcg_seed + 1) >> 16) & 0x7FFF;
i = ((lcg_state = 22695477 * lcg_state + 1) >> 16) & 0x7FFF;
#endif
break;
case V_HISTSIZE: