aboutsummaryrefslogtreecommitdiff
path: root/ext/async/sqlite3async.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2009-10-19 07:50:25 +0000
committerdan <dan@noemail.net>2009-10-19 07:50:25 +0000
commitfd3b22265e3e9968e0bf2d909420c7c5118a4e4e (patch)
treea6aed4e63afeb4cba9cbe5600ca6bc026fa781ce /ext/async/sqlite3async.c
parent1476a28470470aa58125800fbfd0ac581efaead9 (diff)
downloadsqlite-fd3b22265e3e9968e0bf2d909420c7c5118a4e4e.tar.gz
sqlite-fd3b22265e3e9968e0bf2d909420c7c5118a4e4e.zip
Use 64-bit arithmetic in the xRead() method of asyncRead. Fix for [94c04eaadb].
FossilOrigin-Name: ca3e41b0574cfd8d971c2be2114e58273a531970
Diffstat (limited to 'ext/async/sqlite3async.c')
-rw-r--r--ext/async/sqlite3async.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/ext/async/sqlite3async.c b/ext/async/sqlite3async.c
index 11a476129..0cfc7f6ff 100644
--- a/ext/async/sqlite3async.c
+++ b/ext/async/sqlite3async.c
@@ -668,8 +668,8 @@ static int asyncRead(
AsyncFileData *p = ((AsyncFile *)pFile)->pData;
int rc = SQLITE_OK;
sqlite3_int64 filesize;
- int nRead;
sqlite3_file *pBase = p->pBaseRead;
+ sqlite3_int64 iAmt64 = (sqlite3_int64)iAmt;
/* Grab the write queue mutex for the duration of the call */
async_mutex_enter(ASYNC_MUTEX_QUEUE);
@@ -683,11 +683,12 @@ static int asyncRead(
}
if( pBase->pMethods ){
+ sqlite3_int64 nRead;
rc = pBase->pMethods->xFileSize(pBase, &filesize);
if( rc!=SQLITE_OK ){
goto asyncread_out;
}
- nRead = (int)MIN(filesize - iOffset, iAmt);
+ nRead = MIN(filesize - iOffset, iAmt64);
if( nRead>0 ){
rc = pBase->pMethods->xRead(pBase, zOut, nRead, iOffset);
ASYNC_TRACE(("READ %s %d bytes at %d\n", p->zName, nRead, iOffset));
@@ -703,14 +704,20 @@ static int asyncRead(
(pWrite->pFileData==p) ||
(zName && pWrite->pFileData->zName==zName)
)){
+ sqlite3_int64 nCopy;
+ sqlite3_int64 nByte64 = (sqlite3_int64)pWrite->nByte;
+
+ /* Set variable iBeginIn to the offset in buffer pWrite->zBuf[] from
+ ** which data should be copied. Set iBeginOut to the offset within
+ ** the output buffer to which data should be copied. If either of
+ ** these offsets is a negative number, set them to 0.
+ */
sqlite3_int64 iBeginOut = (pWrite->iOffset-iOffset);
sqlite3_int64 iBeginIn = -iBeginOut;
- int nCopy;
-
if( iBeginIn<0 ) iBeginIn = 0;
if( iBeginOut<0 ) iBeginOut = 0;
- nCopy = (int)MIN(pWrite->nByte-iBeginIn, iAmt-iBeginOut);
+ nCopy = MIN(nByte64-iBeginIn, iAmt64-iBeginOut);
if( nCopy>0 ){
memcpy(&((char *)zOut)[iBeginOut], &pWrite->zBuf[iBeginIn], nCopy);
ASYNC_TRACE(("OVERREAD %d bytes at %d\n", nCopy, iBeginOut+iOffset));