[jcifs] SmbComWriteAndX writes corrupt offset to wire
Michael B Allen
mba2000 at ioplex.com
Thu Apr 15 18:46:03 GMT 2004
eglass1 at comcast.net said:
>
>> static void writeInt4( long val, byte[] dst, int dstIndex ) {
>> dst[dstIndex++] = (byte)(val);
>> dst[dstIndex++] = (byte)(val >> 8);
>> dst[dstIndex++] = (byte)(val >> 16);
>> dst[dstIndex++] = (byte)(val >> 32);
>> }
>
> The last shift in writeInt4 should be 24, not 32. It's also faster
> (although
> probably negligibly for our purposes) to do:
>
> static void writeInt4( long val, byte[] dst, int dstIndex ) {
> dst[dstIndex] = (byte)(val);
> dst[++dstIndex] = (byte)(val >>= 8);
> dst[++dstIndex] = (byte)(val >>= 8);
> dst[++dstIndex] = (byte)(val >> 8);
> }
Are we certain that the masks are unnecessary? I suppose I was thinking of
C when I wrote these routines where the highbit is used to indicate the
sign. For example, if an int or short with the highbit is passed to this
and the type is promoted to long will the bit pattern still be what we
expect?
Mike
More information about the jcifs
mailing list