/ Check-in [afcfba0a]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix an error in the previous commit found by corrupt7.test. (CVS 5204)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: afcfba0a8ac46e1d86a0fa2f1fbaeefe8ef10f7d
User & Date: danielk1977 2008-06-11 18:27:55
Context
2008-06-11
18:56
Adjust the error-message text in corrupt7.test. (CVS 5205) check-in: 4a77ff5b user: drh tags: trunk
18:27
Fix an error in the previous commit found by corrupt7.test. (CVS 5204) check-in: afcfba0a user: danielk1977 tags: trunk
18:15
Check that the offsets in the cell-offset array of a b-tree page are within range in sqlite3BtreeInit(). (CVS 5203) check-in: 82f27e28 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/btree.c.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.462 2008/06/11 18:15:30 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
** Including a description of file format and an overview of operation.
*/
#include "btreeInt.h"

................................................................................
  pPage->nFree = nFree;
  if( nFree>=usableSize ){
    /* Free space cannot exceed total page size */
    return SQLITE_CORRUPT_BKPT; 
  }

  /* Check that all the offsets in the cell offset array are within range. */
  mask = ~(((u8)(pBt->pageSize>>7))-1);
  pEnd = &data[cellOffset + pPage->nCell*2];
  for(pOff=&data[cellOffset]; pOff!=pEnd && !((*pOff)&mask); pOff+=2);
  if( pOff!=pEnd ){
    return SQLITE_CORRUPT_BKPT;
  }

  pPage->isInit = 1;







|







 







|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.463 2008/06/11 18:27:55 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
** Including a description of file format and an overview of operation.
*/
#include "btreeInt.h"

................................................................................
  pPage->nFree = nFree;
  if( nFree>=usableSize ){
    /* Free space cannot exceed total page size */
    return SQLITE_CORRUPT_BKPT; 
  }

  /* Check that all the offsets in the cell offset array are within range. */
  mask = ~(((u8)(pBt->pageSize>>8))-1);
  pEnd = &data[cellOffset + pPage->nCell*2];
  for(pOff=&data[cellOffset]; pOff!=pEnd && !((*pOff)&mask); pOff+=2);
  if( pOff!=pEnd ){
    return SQLITE_CORRUPT_BKPT;
  }

  pPage->isInit = 1;