#1 2019-03-09 15:12:40

Greg0r
Member
Registered: 2019-01-28
Posts: 49

How to change header properly in .c sources

I need to change header and have question
I know change is needed also in .pas but wonder about c sources.
Is this enough to change
define SQLITE_FILE_HEADER "SQLite format 3"
in sqlite3.c?

I'm asking becasue
I have found hardcoded strings  with "SQLite format 3" in two places in shell.c

....
static int apndIsOrdinaryDatabaseFile(sqlite3_int64 sz, sqlite3_file *pFile){
  int rc;
  char zHdr[16];
  static const char aSqliteHdr[] = "SQLite format 3";
  if( sz<512 ) return 0;
  rc = pFile->pMethods->xRead(pFile, zHdr, sizeof(zHdr), 0);
  if( rc ) return 0;
  return memcmp(zHdr, aSqliteHdr, sizeof(zHdr))==0;
}
.....

  n = fread(zBuf, 16, 1, f);
  if( n==1 && memcmp(zBuf, "SQLite format 3", 16)==0 ){
    fclose(f);
    return SHELL_OPEN_NORMAL;

Last edited by Greg0r (2019-03-09 15:13:14)

Offline

#2 2019-03-09 15:27:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,656
Website

Re: How to change header properly in .c sources

This is not a question for mORMot itself, but more a Sqlite3 question.

SQLITE_FILE_HEADER is indeed hardcoded in SQlite3 sources.
And documented as such.
See https://www.sqlite.org/fileformat.html# … ase_header

But IIRC you can customize this first 16 bytes to whatever values you expect.
Some editors may refuse to open the file (as our SynDBExplorer), but others may allow to open it, since sqlite3_open() should work even without the signature.
In my opinion, there is NO benefit of obfuscating those magic bytes. More potential pain than gain.

Online

#3 2019-03-10 12:18:27

Greg0r
Member
Registered: 2019-01-28
Posts: 49

Re: How to change header properly in .c sources

Thanks

Offline

Board footer

Powered by FluxBB