summaryrefslogtreecommitdiffstats
path: root/source/smbd/fileio.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-10-18 22:06:35 +0000
committerJeremy Allison <jra@samba.org>1998-10-18 22:06:35 +0000
commitb8b781191dd7d28944d87eec5fa0fbef798e289b (patch)
treea40b2ff81c5186985935313184f53fc38577956d /source/smbd/fileio.c
parent20880966aafb2dbcdfbf979505a2d64a269dd9a8 (diff)
downloadsamba-b8b781191dd7d28944d87eec5fa0fbef798e289b.tar.gz
samba-b8b781191dd7d28944d87eec5fa0fbef798e289b.tar.xz
samba-b8b781191dd7d28944d87eec5fa0fbef798e289b.zip
Fixed sys_lseek and seek_file calls so all returns
are *checked* :-). Jeremy.
Diffstat (limited to 'source/smbd/fileio.c')
-rw-r--r--source/smbd/fileio.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/source/smbd/fileio.c b/source/smbd/fileio.c
index ebc4544a769..c7ffb6412dd 100644
--- a/source/smbd/fileio.c
+++ b/source/smbd/fileio.c
@@ -31,11 +31,20 @@ seek a file. Try to avoid the seek if possible
SMB_OFF_T seek_file(files_struct *fsp,SMB_OFF_T pos)
{
SMB_OFF_T offset = 0;
+ SMB_OFF_T seek_ret;
if (fsp->print_file && lp_postscript(fsp->conn->service))
offset = 3;
- fsp->pos = (sys_lseek(fsp->fd_ptr->fd,pos+offset,SEEK_SET) - offset);
+ seek_ret = sys_lseek(fsp->fd_ptr->fd,pos+offset,SEEK_SET);
+
+ if((seek_ret == -1) || (seek_ret != pos+offset)) {
+ DEBUG(0,("seek_file: sys_lseek failed. Error was %s\n", strerror(errno) ));
+ fsp->pos = -1;
+ return -1;
+ }
+
+ fsp->pos = seek_ret - offset;
DEBUG(10,("seek_file: requested pos = %.0f, new pos = %.0f\n",
(double)(pos+offset), (double)fsp->pos ));
@@ -75,7 +84,7 @@ ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n)
}
#endif
- if (seek_file(fsp,pos) != pos) {
+ if (seek_file(fsp,pos) == -1) {
DEBUG(3,("read_file: Failed to seek to %.0f\n",(double)pos));
return(ret);
}