aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2007-02-06 11:11:08 +0000
committerdrh <drh@noemail.net>2007-02-06 11:11:08 +0000
commit8ebf6707cf6716c55d68e2ba7e62ef820c590050 (patch)
tree0eb443706498a18817c85907d047151e9d1e2123 /src/os_unix.c
parentd7263927f7b53330ad4b7fef608ff0b953435ad8 (diff)
downloadsqlite-8ebf6707cf6716c55d68e2ba7e62ef820c590050.tar.gz
sqlite-8ebf6707cf6716c55d68e2ba7e62ef820c590050.zip
Check the return value of lseek() in os_unix.c to make sure it really worked. (CVS 3628)
FossilOrigin-Name: e4408dd1fd32e6c5057cce0fdfa70eb2d9bd2531
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index c5fa2c0ed..8ac272e5e 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1000,10 +1000,14 @@ int sqlite3UnixIsDirWritable(char *zBuf){
*/
static int seekAndRead(unixFile *id, void *pBuf, int cnt){
int got;
+ i64 newOffset;
#ifdef USE_PREAD
got = pread(id->h, pBuf, cnt, id->offset);
#else
- lseek(id->h, id->offset, SEEK_SET);
+ newOffset = lseek(id->h, id->offset, SEEK_SET);
+ if( newOffset!=id->offset ){
+ return -1;
+ }
got = read(id->h, pBuf, cnt);
#endif
if( got>0 ){
@@ -1043,10 +1047,14 @@ static int unixRead(OsFile *id, void *pBuf, int amt){
*/
static int seekAndWrite(unixFile *id, const void *pBuf, int cnt){
int got;
+ i64 newOffset;
#ifdef USE_PREAD
got = pwrite(id->h, pBuf, cnt, id->offset);
#else
- lseek(id->h, id->offset, SEEK_SET);
+ newOffset = lseek(id->h, id->offset, SEEK_SET);
+ if( newOffset!=id->offset ){
+ return -1;
+ }
got = write(id->h, pBuf, cnt);
#endif
if( got>0 ){