/ Check-in [c4b9c611]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Prevent the in-memory journal read cursor from entering an inconsistent state when it reads the last few bytes out of the journal file. Fix for ticket [7f7f8026eda38].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c4b9c611bdcd85f31d68aaf114ee34a9f27eba6d
User & Date: drh 2016-04-07 18:42:23
Context
2016-04-07
21:22
Prevent the in-memory journal read cursor from entering an inconsistent state when it reads the last few bytes out of the journal file. Fix for ticket [7f7f8026eda38]. check-in: c232b99e user: drh tags: branch-3.12.0
21:14
Add test cases for ticket [7f7f8026eda387d544]. check-in: 87aa9357 user: drh tags: trunk
18:42
Prevent the in-memory journal read cursor from entering an inconsistent state when it reads the last few bytes out of the journal file. Fix for ticket [7f7f8026eda38]. check-in: c4b9c611 user: drh tags: trunk
14:16
Avoid decrementing a pointer off the front end of the buffer in OP_MakeRecord. check-in: 153135bf user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/memjournal.c.

    90     90   #ifdef SQLITE_ENABLE_ATOMIC_WRITE
    91     91     if( (iAmt+iOfst)>p->endpoint.iOffset ){
    92     92       return SQLITE_IOERR_SHORT_READ;
    93     93     }
    94     94   #endif
    95     95   
    96     96     assert( (iAmt+iOfst)<=p->endpoint.iOffset );
           97  +  assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );
    97     98     if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
    98     99       sqlite3_int64 iOff = 0;
    99    100       for(pChunk=p->pFirst; 
   100    101           ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;
   101    102           pChunk=pChunk->pNext
   102    103       ){
   103    104         iOff += p->nChunkSize;
   104    105       }
   105    106     }else{
   106    107       pChunk = p->readpoint.pChunk;
          108  +    assert( pChunk!=0 );
   107    109     }
   108    110   
   109    111     iChunkOffset = (int)(iOfst%p->nChunkSize);
   110    112     do {
   111    113       int iSpace = p->nChunkSize - iChunkOffset;
   112    114       int nCopy = MIN(nRead, (p->nChunkSize - iChunkOffset));
   113    115       memcpy(zOut, (u8*)pChunk->zChunk + iChunkOffset, nCopy);
   114    116       zOut += nCopy;
   115    117       nRead -= iSpace;
   116    118       iChunkOffset = 0;
   117    119     } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );
   118         -  p->readpoint.iOffset = iOfst+iAmt;
          120  +  p->readpoint.iOffset = pChunk ? iOfst+iAmt : 0;
   119    121     p->readpoint.pChunk = pChunk;
   120    122   
   121    123     return SQLITE_OK;
   122    124   }
   123    125   
   124    126   /*
   125    127   ** Free the list of FileChunk structures headed at MemJournal.pFirst.