summaryrefslogtreecommitdiffstats
path: root/source/smbd/reply.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-08-31 15:49:22 +0000
committerJeremy Allison <jra@samba.org>2001-08-31 15:49:22 +0000
commitf2aecd3984505a17ba636634722ed8536d313d5d (patch)
tree48f48300d945e625d2659d28e7ad460b48e9f173 /source/smbd/reply.c
parentb38b63cb9a359858525c03e78de5bbac342c162b (diff)
downloadsamba-f2aecd3984505a17ba636634722ed8536d313d5d.tar.gz
samba-f2aecd3984505a17ba636634722ed8536d313d5d.tar.xz
samba-f2aecd3984505a17ba636634722ed8536d313d5d.zip
Fixed read beyond EOF problem (still needs testing :-).
Jeremy.
Diffstat (limited to 'source/smbd/reply.c')
-rw-r--r--source/smbd/reply.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index ad2236cdf76..38b548979b4 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -2203,7 +2203,10 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
fsp->size = size;
}
- nread = MIN(maxcount,(size - startpos));
+ if (startpos >= size)
+ nread = 0;
+ else
+ nread = MIN(maxcount,(size - startpos));
}
if (nread < mincount)
@@ -2212,9 +2215,11 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
DEBUG( 3, ( "readbraw fnum=%d start=%.0f max=%d min=%d nread=%d\n", fsp->fnum, (double)startpos,
(int)maxcount, (int)mincount, (int)nread ) );
- ret = read_file(fsp,header+4,startpos,nread);
- if (ret < mincount)
- ret = 0;
+ if (nread > 0) {
+ ret = read_file(fsp,header+4,startpos,nread);
+ if (ret < mincount)
+ ret = 0;
+ }
_smb_setlen(header,ret);
if (write_data(smbd_server_fd(),header,4+ret) != 4+ret)