[jcifs] file pointer wrong after readFully in SMBRandomAccessFile

Stefan Risto risto at web.de
Tue Apr 9 05:48:05 MDT 2013


Richard Heap <richardheap <at> london.com> writes:

> 
> 
>     Hi Mike et alI believe that the file pointer is being
>           advanced too far following a read fully.For example,     
SmbRandomAccessFile raf = new
>                   SmbRandomAccessFile(new
>                                 SmbFile("smb://username:pwd <at>
server/share/foo/bar/file.dat"),
>                   "r");
>                         raf.readFully(new byte[512]);
>                         System.out.println(raf.getFilePointer());reads 512
bytes but prints 1024. A subsequent read takes
>                         place at 1024 instead of 512.It looks like
readFully may be
>                           incrementing the file pointer as well as
>                           read(), which is called by
>                           readFully, causing a double increment.Best
Regards and thanks again
>                             for jcifs.Richard
>   


I can confirm this issue. I observed the same behaviour. A workaround for me
is to adjust the file pointer manually after every readFully using seek, but
this is very silly.
Using this workaround I can now open a zip on the smb server and extract a
single file without streaming the whole zip file to the client (I use a
patched version of Apache commons compress' ZipFile for that)

Please fix that bug so I can get rid of the workaround.

Regards, 
Stefan





More information about the jCIFS mailing list