Optimize a database corruption test inside of the OP_Column opcode.

FossilOrigin-Name: 005e5b388a8a97bca6d1f0e06c40d68d92aa1212
This commit is contained in:
drh 2014-10-13 23:39:02 +00:00
parent facf47a891
commit 8dd8362d64
3 changed files with 15 additions and 14 deletions

View File

@ -1,5 +1,5 @@
C Use\sthe\spadding\sword\sin\sthe\sMem\sobject\sas\stemporary\sstorage\sfor\nserial_type\svalue\sin\sOP_Record,\sand\sthus\savoid\sa\sredundant\scomputation\sof\nthe\sserial_type\sfor\seach\scolumn.
D 2014-10-13T20:12:47.457
C Optimize\sa\sdatabase\scorruption\stest\sinside\sof\sthe\sOP_Column\sopcode.
D 2014-10-13T23:39:02.463
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -289,7 +289,7 @@ F src/update.c 729f6f18fc27740591d085e1172cebe311144bf0
F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c
F src/util.c 4006c01772bd8d8ac4306d523bbcee41d3e392d8
F src/vacuum.c 59f03f92bcff57faa6a8ca256eb29ccddfb0614a
F src/vdbe.c 8755e3bb0d7d26b2b156c6f29ddd6b3d32b77df2
F src/vdbe.c 5ee15a66ce07e0482b92aa29e4dd0c5827a22d79
F src/vdbe.h 09f5b4e3719fa454f252322b1cdab5cf1f361327
F src/vdbeInt.h e2a060a55ee18a6ab973353a5e2ec7ee569bf787
F src/vdbeapi.c 37a6c6ae284a97bcace365f2f0a225680c0499d9
@ -1204,7 +1204,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 04892f8ba6c55cec4fe37bfe59b6349fd2a40698
R b0e17ef60b5aa0edd0fe18cf5fe3de58
P 4b3b65ee5ea61e9b9671ca027940bf02689cb890
R 42e26b1c48be06a100ad5530a5448c12
U drh
Z 6462e46ba313ee1bcf094c3a26197f24
Z 6b074ae9a762ef61cbe684b68fc815ba

View File

@ -1 +1 @@
4b3b65ee5ea61e9b9671ca027940bf02689cb890
005e5b388a8a97bca6d1f0e06c40d68d92aa1212

View File

@ -2417,15 +2417,16 @@ case OP_Column: {
sMem.flags = MEM_Null;
}
/* If we have read more header data than was contained in the header,
** or if the end of the last field appears to be past the end of the
** record, or if the end of the last field appears to be before the end
** of the record (when all fields present), then we must be dealing
** with a corrupt database.
/* The record is corrupt if any of the following are true:
** (1) the bytes of the header extend past the declared header size
** (zHdr>zEndHdr)
** (2) the entire header was used but not all data was used
** (zHdr==zEndHdr && offset!=pC->payloadSize)
** (3) the end of the data extends beyond the end of the record.
** (offset > pC->payloadSize)
*/
if( (zHdr > zEndHdr)
if( (zHdr>=zEndHdr && (zHdr>zEndHdr || offset!=pC->payloadSize))
|| (offset > pC->payloadSize)
|| (zHdr==zEndHdr && offset!=pC->payloadSize)
){
rc = SQLITE_CORRUPT_BKPT;
goto op_column_error;