[jcifs] Resyncing? Out of Phase

Michael B Allen ioplex at gmail.com
Wed Aug 10 23:07:26 MDT 2011


On Wed, Aug 10, 2011 at 4:21 PM, Sebastian Sickelmann
<sebastian.sickelmann at gmx.de> wrote:
> Hi,
>
> In SMBTransport there is the following code fragment
>                                        /* out of phase maybe? */
>                          /* inch forward 1 byte and try again */
>            for (int i = 0; i < 35; i++) {
>                sbuf[i] = sbuf[i + 1];
>            }
>            int b;
>            if ((b = in.read()) == -1) return null;
>            sbuf[35] = (byte)b;
>
>
> which maybe can be replaced by
>
>                                        /* out of phase maybe? */
>                          /* inch forward 1 byte and try again */
>            if (log.level >= 5) {
>                log.println( "maybe we are out of phase. Try resyncing" );
>            }
>            System.arraycopy( sbuf, 1, sbuf, 0, 35 );
>            if (log.level >= 6) {
>                jcifs.util.Hexdump.hexdump( log, sbuf, 4, 31 );
>            }
>            if (readn( in, sbuf, 35, 1 ) == -1) {
>                return null;
>            }
>
> Is "out of phase" an often case?

Hi Sebastian,

No. It should never happen. I'm not sure if that code has ever even
been tested. I think the purpose of that code is to gracefully handle
skipping a message that JCIFS could not decode for some reason. So
there is really no reason for "improvement" here.

Mike

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


More information about the jCIFS mailing list