aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-08-29 21:26:26 +0000
committerdrh <drh@noemail.net>2013-08-29 21:26:26 +0000
commit0c9a8e345e99a056a2f5f4a8346127a178dde1da (patch)
tree186f660fbc7266749126c0e01c0ffc280641004d /src/os_unix.c
parent8bff07a55f559223526c93fcf013192577e777dc (diff)
downloadsqlite-0c9a8e345e99a056a2f5f4a8346127a178dde1da.tar.gz
sqlite-0c9a8e345e99a056a2f5f4a8346127a178dde1da.zip
Never leave an open file descriptor pointing into the middle of the
database file if the file descriptor number is 2 or less. FossilOrigin-Name: 3426673e4659eb68dbd14a3e41d4620d748432db
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 580f8e60e..32201c988 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -588,6 +588,7 @@ static int robust_open(const char *z, int f, mode_t m){
osFchmod(fd, m);
}
}
+ if( fd<=2 ) lseek(fd, 0, SEEK_END);
#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
#endif
@@ -3133,6 +3134,7 @@ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
pBuf = (void*)(got + (char*)pBuf);
}
}while( got>0 );
+ if( id->h<=2 ) lseek(id->h, 0, SEEK_END);
TIMER_END;
OSTRACE(("READ %-3d %5d %7lld %llu\n",
id->h, got+prior, offset-prior, TIMER_ELAPSED));
@@ -3232,6 +3234,7 @@ static int seekAndWriteFd(
rc = osWrite(fd, pBuf, nBuf);
}while( rc<0 && errno==EINTR );
#endif
+ if( fd<=2 ) lseek(fd, 0, SEEK_END);
TIMER_END;
OSTRACE(("WRITE %-3d %5d %7lld %llu\n", fd, rc, iOff, TIMER_ELAPSED));