SQLite

Check-in [65ad6c55f1]
Login

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

Overview
Comment:Use memmove() instead of memcpy() in a place where buffers might overlap if the database file is badly corrupted, to prevent warnings from ASAN and valgrind.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 65ad6c55f1ba9bc2f75afffa3adaf19f145fad7ac9a00ccce6372e9a2cc4341b
User & Date: drh 2019-01-24 13:36:47.895
Context
2019-01-24
14:16
Change a integer variable in sqlite3VdbeRecordUnpack() to unsigned in order to avoid any possibility of an integer overflow. (check-in: 1b536f6fd8 user: drh tags: trunk)
13:36
Use memmove() instead of memcpy() in a place where buffers might overlap if the database file is badly corrupted, to prevent warnings from ASAN and valgrind. (check-in: 65ad6c55f1 user: drh tags: trunk)
04:44
Remove an unreachable branch. (check-in: 4c976f1713 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
8347
8348
8349
8350
8351
8352
8353




8354
8355
8356
8357
8358
8359
8360
8361
                                 iAmt-nData);
      if( rc ) return rc;
      iAmt = nData;
    }
    if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
      int rc = sqlite3PagerWrite(pPage->pDbPage);
      if( rc ) return rc;




      memcpy(pDest, ((u8*)pX->pData) + iOffset, iAmt);
    }
  }
  return SQLITE_OK;
}

/*
** Overwrite the cell that cursor pCur is pointing to with fresh content







>
>
>
>
|







8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
                                 iAmt-nData);
      if( rc ) return rc;
      iAmt = nData;
    }
    if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
      int rc = sqlite3PagerWrite(pPage->pDbPage);
      if( rc ) return rc;
      /* In a corrupt database, it is possible for the source and destination
      ** buffers to overlap.  This is harmless since the database is already
      ** corrupt but it does cause valgrind and ASAN warnings.  So use
      ** memmove(). */
      memmove(pDest, ((u8*)pX->pData) + iOffset, iAmt);
    }
  }
  return SQLITE_OK;
}

/*
** Overwrite the cell that cursor pCur is pointing to with fresh content
Changes to test/fuzzdata7.db.

cannot compute difference between binary files