1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Make sure the size parameter to read and write VFS methods in the unix VFS

do not become too big or go negative.  This was not actually possible in the
current code.  The checks are added to make sure some future bug does not
make it possible.

FossilOrigin-Name: daebe3bd2d9bd7b6f876a8110cf5045eb3fee078
This commit is contained in:
drh
2012-10-01 12:16:26 +00:00
parent c9a5326974
commit c1fd2cfed2
3 changed files with 12 additions and 8 deletions

View File

@@ -3010,6 +3010,8 @@ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
i64 newOffset;
#endif
TIMER_START;
assert( cnt==(cnt&0x1ffff) );
cnt &= 0x1ffff;
do{
#if defined(USE_PREAD)
got = osPread(id->h, pBuf, cnt, offset);
@@ -3099,6 +3101,8 @@ static int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int cnt){
#if (!defined(USE_PREAD) && !defined(USE_PREAD64))
i64 newOffset;
#endif
assert( cnt==(cnt&0x1ffff) );
cnt &= 0x1ffff;
TIMER_START;
#if defined(USE_PREAD)
do{ got = osPwrite(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR );