[2112] in Kerberos-V5-bugs
krb5.b5 shs routine
daemon@ATHENA.MIT.EDU (CodeWarrior)
Tue Jul 23 18:01:01 1996
To: krb5-bugs@MIT.EDU
Date: Tue, 23 Jul 1996 17:51:58 -0400 (EDT)
Reply-To: codewarrior@daemon.org (CodeWarrior)
From: codewarrior@daemon.org (CodeWarrior)
Return-Receipt-To: receipts@daemon.org
in the file: .../krb5-beta6/src/lib/crypto/sha/shs.c:
void longReverse( LONG *buffer, int byteCount )
{
LONG value;
static int init = 0;
char *cp;
switch (init) {
case 0:
cp = (char *) &init;
if (*cp == 1) {
init=2;
break;
}
init=1;
/* fall through - MSB */
case 1:
return;
}
byteCount /= sizeof( LONG );
while( byteCount-- ) {
value = *buffer;
value = ( ( value & 0xFF00FF00L ) >> 8 ) |
( ( value & 0x00FF00FFL ) << 8 );
*buffer++ = ( value << 16 ) | ( value >> 16 );
}
}
doesn't work. first time in, init is 0. switch block for 1 re-casts
the pointer and derefences the first char (for endian-ness, i assume)
and since init is 0, this char is 0. it skips the if, sets init to 1,
and falls through to the return. let's change case 0 to this:
case 0:
init=2;
cp = (char *) &init;
if (*cp == 2)
break;
init=1;
and now it will break out on little endian machines on the first time
in and execute the swap loop. on subsequent calls, it will "skip" the
switch altogether.
--
|-----< "CODE WARRIOR" >-----|
andrew@echonyc.com (TheMan) * "pennies are cheap. they're
codewarrior@daemon.org a dime a dozen...almost."
warfare@graffiti.com * "information is power -- share the wealth."