[548] in Kerberos-V5-bugs
Re: Another minor bug in v4admind
daemon@ATHENA.MIT.EDU (grossa@SDSC.EDU)
Thu Jun 30 01:50:33 1994
Date: Wed, 29 Jun 94 22:38:57 PDT
From: grossa@SDSC.EDU
To: eichin@MIT.EDU
Cc: kerberos@MIT.EDU, krb5-bugs@MIT.EDU
> >> I'm sorry I don't have a patch for this, but I'm not sure what to
> >> use as the test for big/little endian-ness.
>
> One should not *care* which endian-ness with the new macros. On a
> big-endian platform, that code should do exactly the same thing as the
> replacement MSBFIRST code...
>
> However, I see a typo in the four_bytes version (a few pair of missing
> parentheses); try using:
>
> #define four_bytes_vax_to_nets(x) ((((((x[3]<<8)|x[2])<<8)|x[1])<<8)|x[0])
>
> and see if that gets the correct behavior.
> _Mark_
Hello,
I see what the real problem is now. The x[i]'s are being typecast
as signed ints and when the high bit is set, the sign extension is
killing all of the previous bytes. The following macros fix the problem:
#define four_bytes_vax_to_nets(x) \
(((((((x[3]&0xff)<<8)|(x[2]&0xff))<<8)|(x[1]&0xff))<<8)|(x[0]&0xff))
#define two_bytes_vax_to_nets(x) (((x[1]&0xff)<<8)|(x[0]&0xff))
Alternatively, one could cast all x[i]'s as unsigned chars.
Thank you,
Andrew Gross