summaryrefslogtreecommitdiff
path: root/source/smbd/predict.c
diff options
context:
space:
mode:
authorcvs2svn Import User <samba-bugs@samba.org>1997-10-15 01:38:14 +0000
committercvs2svn Import User <samba-bugs@samba.org>1997-10-15 01:38:14 +0000
commitdc1f10efa87576a0289fa71aaeed015a3675b029 (patch)
treefca7a02192adb888fe6b4d239c5d1fa32d0a08ca /source/smbd/predict.c
parent332f78bbc945c327069e9c9e29c7137c8cbd5c02 (diff)
parenta173a1495c50b5ad1f6b47710cf4b4a7a2226b46 (diff)
downloadsamba-1.9.17p3.tar.gz
This commit was manufactured by cvs2svn to create tagsamba-1.9.17p3
'release-1-9-17p3'.
Diffstat (limited to 'source/smbd/predict.c')
-rw-r--r--source/smbd/predict.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/source/smbd/predict.c b/source/smbd/predict.c
index 691d8fbb4e0..7d6b2498f5a 100644
--- a/source/smbd/predict.c
+++ b/source/smbd/predict.c
@@ -53,24 +53,37 @@ int read_predict(int fd,int offset,char *buf,char **ptr,int num)
offset >= rp_offset &&
possible>0 &&
smb_last_time-rp_time < rp_timeout)
- {
- ret = possible;
- if (buf)
- memcpy(buf,rp_buffer + (offset-rp_offset),possible);
- else
- *ptr = rp_buffer + (offset-rp_offset);
- DEBUG(5,("read-prediction gave %d bytes of %d\n",ret,num));
- }
+ {
+ ret = possible;
+ if (buf)
+ memcpy(buf,rp_buffer + (offset-rp_offset),possible);
+ else
+ *ptr = rp_buffer + (offset-rp_offset);
+ DEBUG(5,("read-prediction gave %d bytes of %d\n",ret,num));
+ }
if (ret == num) {
predict_skip = True;
} else {
- predict_skip = False;
+ struct stat rp_stat;
+
+ /* Find the end of the file - ensure we don't
+ read predict beyond it. */
+ if(fstat(fd,&rp_stat) < 0)
+ {
+ DEBUG(0,("read-prediction failed on fstat. Error was %s\n", strerror(errno)));
+ predict_skip = True;
+ }
+ else
+ {
+ predict_skip = False;
- /* prepare the next prediction */
- rp_predict_fd = fd;
- rp_predict_offset = offset + num;
- rp_predict_length = num;
+ /* prepare the next prediction */
+ rp_predict_fd = fd;
+ /* Make sure we don't seek beyond the end of the file. */
+ rp_predict_offset = MIN((offset + num),rp_stat.st_size);
+ rp_predict_length = num;
+ }
}
if (ret < 0) ret = 0;