/ Check-in [005e5b38]
Login

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

Overview
Comment:Optimize a database corruption test inside of the OP_Column opcode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:005e5b388a8a97bca6d1f0e06c40d68d92aa1212
User & Date: drh 2014-10-13 23:39:02
Context
2014-10-14
20:25
Make sure new sqlite3_vtab objects created by the xCreate() virtual table method are initialized by the system, in accordance with the documentation. check-in: eab82330 user: drh tags: trunk
14:17
Merge from trunk recent micro-optimizations and the fix for the DESC index GROUP BY ORDER BY bug. check-in: 880df756 user: drh tags: apple-osx
13:41
Merge recent trunk micro-optimizations and the DESC index GROUP BY ORDER BY bug fix into the sessions branch. check-in: 83d4114f user: drh tags: sessions
2014-10-13
23:39
Optimize a database corruption test inside of the OP_Column opcode. check-in: 005e5b38 user: drh tags: trunk
20:12
Use the padding word in the Mem object as temporary storage for serial_type value in OP_Record, and thus avoid a redundant computation of the serial_type for each column. check-in: 4b3b65ee user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  2413   2413         pC->nHdrParsed = i;
  2414   2414         pC->iHdrOffset = (u32)(zHdr - zData);
  2415   2415         if( pC->aRow==0 ){
  2416   2416           sqlite3VdbeMemRelease(&sMem);
  2417   2417           sMem.flags = MEM_Null;
  2418   2418         }
  2419   2419     
  2420         -      /* If we have read more header data than was contained in the header,
  2421         -      ** or if the end of the last field appears to be past the end of the
  2422         -      ** record, or if the end of the last field appears to be before the end
  2423         -      ** of the record (when all fields present), then we must be dealing 
  2424         -      ** with a corrupt database.
         2420  +      /* The record is corrupt if any of the following are true:
         2421  +      ** (1) the bytes of the header extend past the declared header size
         2422  +      **          (zHdr>zEndHdr)
         2423  +      ** (2) the entire header was used but not all data was used
         2424  +      **          (zHdr==zEndHdr && offset!=pC->payloadSize)
         2425  +      ** (3) the end of the data extends beyond the end of the record.
         2426  +      **          (offset > pC->payloadSize)
  2425   2427         */
  2426         -      if( (zHdr > zEndHdr)
         2428  +      if( (zHdr>=zEndHdr && (zHdr>zEndHdr || offset!=pC->payloadSize))
  2427   2429          || (offset > pC->payloadSize)
  2428         -       || (zHdr==zEndHdr && offset!=pC->payloadSize)
  2429   2430         ){
  2430   2431           rc = SQLITE_CORRUPT_BKPT;
  2431   2432           goto op_column_error;
  2432   2433         }
  2433   2434       }
  2434   2435   
  2435   2436       /* If after trying to extra new entries from the header, nHdrParsed is