[jcifs] Problem with sign in NDR decoder

Michael B Allen ioplex at gmail.com
Thu Jun 18 15:39:45 GMT 2009


On Thu, Jun 18, 2009 at 9:26 AM, Jose Luis Martinez
Avial<jlmartinez at pb-santander.com> wrote:
> Hi all,
>   This is not really a jCIFS question, but since the Ndr is part of jCIFS, I
> think this is the best place to ask this question. I'm using the NdrBuffer
> present in the jCIFS library to parse a PAC from a Kerberos Ticket. I've
> found some problems when decoding numbers. For example:
>
> I've a 32 bits little-endian number. The hex dump is 92 0E F7 C2(the int
> value should be 3270971026). But calling ndr.dec_ndr_long(array) gives me
> -1023996270, which is the C2 value of the array. It seems that the method
>
> Encdec.dec_uint32le(buf, index);
>
> is not returning a uint number really. Is this a bug, or it's thw way it
> should be?

Hi Jose,

Java does not support unsigned integers. But with care you can treat
them as unsigned. You just have to be very careful about performing
various operations like simple arithmetic. In some cases you will need
to cast the an int to a long before you can do something meaningful
with it. But in practice, I think you'll find that you don't really
need many special cases in your code.

The only real problem is displaying values which as you have found out
can be confusing. For this, I recommend that you use the
jcifs.util.Hexdump class and try to output things mostly in
hexidecimal if only for debugging purposes. For example the code:

  int i = -1023996270;
  System.out.println("0x" + Hexdump.toHexString(i, 8));

will print 8 nibbles of the supplied in integer in hexidecimal:

  0xC2F70E92

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/


More information about the jcifs mailing list