SQLite

Check-in [d64d181c79]
Login

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

Overview
Comment:Check for a failure in the call to sqlite3PagerPagecount() from within sqlite3PagerWrite(). (Error discovered by valgrind.)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d64d181c79aee3501be6f7eb8c11ab2cc9a8d63c
User & Date: drh 2010-04-02 13:25:22.000
Context
2010-04-03
13:08
Silently abandon a rollback if the journal has been truncated. (check-in: 7626f6c9ea user: drh tags: trunk)
2010-04-02
13:25
Check for a failure in the call to sqlite3PagerPagecount() from within sqlite3PagerWrite(). (Error discovered by valgrind.) (check-in: d64d181c79 user: drh tags: trunk)
12:55
Take care to avoid a buffer over-read when adding a KEYINFO structure to the P4 parameter of an opcode. (check-in: 937b931a7c user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pager.c.
4318
4319
4320
4321
4322
4323
4324
4325

4326
4327
4328
4329
4330
4331
4332

    /* This trick assumes that both the page-size and sector-size are
    ** an integer power of 2. It sets variable pg1 to the identifier
    ** of the first page of the sector pPg is located on.
    */
    pg1 = ((pPg->pgno-1) & ~(nPagePerSector-1)) + 1;

    sqlite3PagerPagecount(pPager, (int *)&nPageCount);

    if( pPg->pgno>nPageCount ){
      nPage = (pPg->pgno - pg1)+1;
    }else if( (pg1+nPagePerSector-1)>nPageCount ){
      nPage = nPageCount+1-pg1;
    }else{
      nPage = nPagePerSector;
    }







|
>







4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333

    /* This trick assumes that both the page-size and sector-size are
    ** an integer power of 2. It sets variable pg1 to the identifier
    ** of the first page of the sector pPg is located on.
    */
    pg1 = ((pPg->pgno-1) & ~(nPagePerSector-1)) + 1;

    rc = sqlite3PagerPagecount(pPager, (int *)&nPageCount);
    if( rc ) return rc;
    if( pPg->pgno>nPageCount ){
      nPage = (pPg->pgno - pg1)+1;
    }else if( (pg1+nPagePerSector-1)>nPageCount ){
      nPage = nPageCount+1-pg1;
    }else{
      nPage = nPagePerSector;
    }