SQLite

Check-in [afcfba0a8a]
Login

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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: afcfba0a8ac46e1d86a0fa2f1fbaeefe8ef10f7d
User & Date: danielk1977 2008-06-11 18:27:55.000
Context
2008-06-11
18:56
Adjust the error-message text in corrupt7.test. (CVS 5205) (check-in: 4a77ff5b58 user: drh tags: trunk)
18:27
Fix an error in the previous commit found by corrupt7.test. (CVS 5204) (check-in: afcfba0a8a 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: 82f27e28ee user: danielk1977 tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
** 2004 April 6
**
** The author disclaims copyright to this source code.  In place of
** 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"












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
** 2004 April 6
**
** The author disclaims copyright to this source code.  In place of
** 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"

961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
  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;







|







961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
  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;