/ Check-in [fb311d6f]
Login

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

Overview
Comment:Add documentation to make it clear that short reads from xRead in the VFS must be zero-filled. (CVS 5867)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fb311d6f4098a08f05b3fac9a2a7e2a53c38bb5f
User & Date: drh 2008-11-07 00:06:18
Context
2008-11-07
00:24
Prevent a rollback from crashing if the sector-size field of the rollback journal is corrupted. (CVS 5868) check-in: cf9d1d93 user: drh tags: trunk
00:06
Add documentation to make it clear that short reads from xRead in the VFS must be zero-filled. (CVS 5867) check-in: fb311d6f user: drh tags: trunk
2008-11-06
15:33
Fix a bug in the CAST operator associated with the column cache. (CVS 5866) check-in: 1b6a5140 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/os_os2.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   ******************************************************************************
    12     12   **
    13     13   ** This file contains code that is specific to OS/2.
    14     14   **
    15         -** $Id: os_os2.c,v 1.57 2008/10/13 21:46:47 pweilbacher Exp $
           15  +** $Id: os_os2.c,v 1.58 2008/11/07 00:06:18 drh Exp $
    16     16   */
    17     17   
    18     18   #include "sqliteInt.h"
    19     19   
    20     20   #if SQLITE_OS_OS2
    21     21   
    22     22   /*
................................................................................
   120    120     }
   121    121     if( DosRead( pFile->h, pBuf, amt, &got ) != NO_ERROR ){
   122    122       return SQLITE_IOERR_READ;
   123    123     }
   124    124     if( got == (ULONG)amt )
   125    125       return SQLITE_OK;
   126    126     else {
          127  +    /* Unread portions of the input buffer must be zero-filled */
   127    128       memset(&((char*)pBuf)[got], 0, amt-got);
   128    129       return SQLITE_IOERR_SHORT_READ;
   129    130     }
   130    131   }
   131    132   
   132    133   /*
   133    134   ** Write data from a buffer into a file.  Return SQLITE_OK on success

Changes to src/os_unix.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   ******************************************************************************
    12     12   **
    13     13   ** This file contains code that is specific to Unix systems.
    14     14   **
    15         -** $Id: os_unix.c,v 1.207 2008/10/16 13:27:41 danielk1977 Exp $
           15  +** $Id: os_unix.c,v 1.208 2008/11/07 00:06:18 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #if SQLITE_OS_UNIX              /* This file is used on unix only */
    19     19   
    20     20   /*
    21     21   ** If SQLITE_ENABLE_LOCKING_STYLE is defined and is non-zero, then several
    22     22   ** alternative locking implementations are provided:
................................................................................
   893    893     assert( id );
   894    894     got = seekAndRead((unixFile*)id, offset, pBuf, amt);
   895    895     if( got==amt ){
   896    896       return SQLITE_OK;
   897    897     }else if( got<0 ){
   898    898       return SQLITE_IOERR_READ;
   899    899     }else{
          900  +    /* Unread parts of the buffer must be zero-filled */
   900    901       memset(&((char*)pBuf)[got], 0, amt-got);
   901    902       return SQLITE_IOERR_SHORT_READ;
   902    903     }
   903    904   }
   904    905   
   905    906   /*
   906    907   ** Seek to the offset in id->offset then read cnt bytes into pBuf.

Changes to src/os_win.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   ******************************************************************************
    12     12   **
    13     13   ** This file contains code that is specific to windows.
    14     14   **
    15         -** $Id: os_win.c,v 1.136 2008/10/22 16:55:47 shane Exp $
           15  +** $Id: os_win.c,v 1.137 2008/11/07 00:06:18 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #if SQLITE_OS_WIN               /* This file is used for windows only */
    19     19   
    20     20   
    21     21   /*
    22     22   ** A Note About Memory Allocation:
................................................................................
   662    662     }
   663    663     if( !ReadFile(pFile->h, pBuf, amt, &got, 0) ){
   664    664       return SQLITE_IOERR_READ;
   665    665     }
   666    666     if( got==(DWORD)amt ){
   667    667       return SQLITE_OK;
   668    668     }else{
          669  +    /* Unread parts of the buffer must be zero-filled */
   669    670       memset(&((char*)pBuf)[got], 0, amt-got);
   670    671       return SQLITE_IOERR_SHORT_READ;
   671    672     }
   672    673   }
   673    674   
   674    675   /*
   675    676   ** Write data from a buffer into a file.  Return SQLITE_OK on success

Changes to src/sqlite.h.in.

    26     26   ** on how SQLite interfaces are suppose to operate.
    27     27   **
    28     28   ** The name of this file under configuration management is "sqlite.h.in".
    29     29   ** The makefile makes some minor changes to this file (such as inserting
    30     30   ** the version number) and changes its name to "sqlite3.h" as
    31     31   ** part of the build process.
    32     32   **
    33         -** @(#) $Id: sqlite.h.in,v 1.408 2008/11/04 14:48:23 drh Exp $
           33  +** @(#) $Id: sqlite.h.in,v 1.409 2008/11/07 00:06:18 drh Exp $
    34     34   */
    35     35   #ifndef _SQLITE3_H_
    36     36   #define _SQLITE3_H_
    37     37   #include <stdarg.h>     /* Needed for the definition of va_list */
    38     38   
    39     39   /*
    40     40   ** Make sure we can call this stuff from C++.
................................................................................
   678    678   ** are aligned to an address which is an integer multiple of
   679    679   ** nnn are atomic.  The SQLITE_IOCAP_SAFE_APPEND value means
   680    680   ** that when data is appended to a file, the data is appended
   681    681   ** first then the size of the file is extended, never the other
   682    682   ** way around.  The SQLITE_IOCAP_SEQUENTIAL property means that
   683    683   ** information is written to disk in the same order as calls
   684    684   ** to xWrite().
          685  +**
          686  +** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
          687  +** in the unread portions of the buffer with zeros.  A VFS that
          688  +** fails to zero-fill short reads might seem to work.  However,
          689  +** failure to zero-fill short reads will eventually lead to
          690  +** database corruption.
   685    691   */
   686    692   typedef struct sqlite3_io_methods sqlite3_io_methods;
   687    693   struct sqlite3_io_methods {
   688    694     int iVersion;
   689    695     int (*xClose)(sqlite3_file*);
   690    696     int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
   691    697     int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst);