are partial read responses legal

Michael B Allen mba2000 at ioplex.com
Mon May 3 05:44:23 GMT 2004


Steve French said:
> Is it legal or common for a server to return less on an SMBReadX than
> the client asked when there is more data and the read falls within the
> negotiated buffer size?
>
> The SNIA spec notes that if read is larger than negotiated buffer size
> the server "may arbitrarily decide" to return fewer than MaxCount bytes,
> perhaps implying that I would be ok in changing my current read code
> from something like
>
> 	while(bytes_to_reads && (rc == 0)) {
> 		SMBRead(bytes_to_read)
> 		decrease bytes_to_read by bytes read
> 	}
>
> to something that checks whether the bytes read was less than negotiated
> size before deciding to retry again on a read that is going to return 0
> bytes.  This also could be in combination with a check to ensure that
> the bytes read matches what we expect is the end of file.

That would be bold. However, jCIFS had a bug for a very long time that
horribly miscalculated bytes_to_read if the server returned a short-count.
No one ever complained and I only noticed the problem when inspecting that
code for other reasons.

Mike


More information about the samba-technical mailing list