Fossil

Changes On Branch nameofexe-appendvfs-check
Login

Changes On Branch nameofexe-appendvfs-check

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

Changes In Branch nameofexe-appendvfs-check Excluding Merge-Ins

This is equivalent to a diff from 491b986d to 169a3dab

2022-03-01
21:02
Ensure that db_open()'s db-is-an-appendvfs-binary check uses canonicalized filenames to avoid the problem reported in forum post 16880a28aad1a868. ... (check-in: ab7ad234 user: stephan tags: trunk)
16:21
Fix an unused var warning in windows ... (Closed-Leaf check-in: 169a3dab user: mgagnon tags: nameofexe-appendvfs-check)
2022-02-28
23:32
Calling db_open() to determine if a given repository is valid rather than a hand-rolled sqlite3_open() call. This then allows us to call db_looks_like_a_repository() to determine if the DB is a valid repo rather than duplicate the checks it already has in another nearby context. This is part of the apndvfs vs normal-case stuff done in prior commits, consolidating the notion of "valid" to a single spot in the code. ... (check-in: 69145d9d user: wyoung tags: trunk)
21:30
Resolve the bug revealed in forum post 16880a28aad1a868 in which the db_open() appendvfs check can misinteract with g.nameOfExe. This is in a branch until a Windows user can confirm that the g.nameOfExe change in main.c behaves as desired on Windows. This was a collaborative bug fix via /chat, not my own. Edit: test success on Windows reported by Martin G. ... (check-in: ec02acfd user: stephan tags: nameofexe-appendvfs-check)
20:49
Since checkin [d8c32ebdff], file_fullexename() function is supported windows, remove comment saying otherwize. (no code change) ... (check-in: 491b986d user: mgagnon tags: trunk)
20:35
Simplified an overly-clever test for a file size being an even multiple of 512 bytes. Compiler Explorer says GCC 11 generates the same code both ways, at least, and it isn't in a CPU-critical code path anyway. Also added a comment referring to this new, simplified code, to prevent a recurrence of the problem fixed by the prior commit. ... (check-in: c67d5401 user: wyoung tags: trunk)

Changes to src/db.c.

1633
1634
1635
1636
1637
1638
1639

1640
1641





1642

1643
1644
1645
1646
1647
1648

1649
1650
1651
1652
1653
1654
1655
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647

1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662







+


+
+
+
+
+
-
+






+







/*
** Open a database file.  Return a pointer to the new database
** connection.  An error results in process abort.
*/
LOCAL sqlite3 *db_open(const char *zDbName){
  int rc;
  sqlite3 *db;
  Blob bNameCheck = BLOB_INITIALIZER;

  if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName);
  file_canonical_name(zDbName, &bNameCheck, 0)
    /* For purposes of the apndvfs check, g.nameOfExe and zDbName must
    ** both be canonicalized, else chances are very good that they
    ** will not match even if they're the same file. Details:
    ** https://fossil-scm.org/forum/forumpost/16880a28aad1a868 */;
  if( strcmp(zDbName, g.nameOfExe)==0 ){
  if( strcmp(blob_str(&bNameCheck), g.nameOfExe)==0 ){
    extern int sqlite3_appendvfs_init(
      sqlite3 *, char **, const sqlite3_api_routines *
    );
    sqlite3_appendvfs_init(0,0,0);
    g.zVfsName = "apndvfs";
  }
  blob_zero(&bNameCheck);
  rc = sqlite3_open_v2(
       zDbName, &db,
       SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
       g.zVfsName
  );
  if( rc!=SQLITE_OK ){
    db_err("[%s]: %s", zDbName, sqlite3_errmsg(db));

Changes to src/main.c.

418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441

442
443
444
445
446
447
448
449
418
419
420
421
422
423
424



425
426
427
428
429
430
431
432
433





434

435
436
437
438
439
440
441







-
-
-









-
-
-
-
-
+
-







  unsigned int i, j, k;     /* Loop counters */
  int n;                    /* Number of bytes in one line */
  unsigned int nArg;        /* Number of new arguments */
  char *z;                  /* General use string pointer */
  char **newArgv;           /* New expanded g.argv under construction */
  const char *zFileName;    /* input file name */
  FILE *inFile;             /* input FILE */
#if defined(_WIN32)
  wchar_t buf[MAX_PATH];
#endif

  g.argc = argc;
  g.argv = argv;
  sqlite3_initialize();
#if defined(_WIN32) && defined(BROKEN_MINGW_CMDLINE)
  for(i=0; i<g.argc; i++) g.argv[i] = fossil_mbcs_to_utf8(g.argv[i]);
#else
  for(i=0; i<g.argc; i++) g.argv[i] = fossil_path_to_utf8(g.argv[i]);
#endif
#if defined(_WIN32)
  GetModuleFileNameW(NULL, buf, MAX_PATH);
  g.nameOfExe = fossil_path_to_utf8(buf);
#else
  g.nameOfExe = g.argv[0];
  g.nameOfExe = file_fullexename(g.argv[0]);
#endif
  for(i=1; i<g.argc-1; i++){
    z = g.argv[i];
    if( z[0]!='-' ) continue;
    z++;
    if( z[0]=='-' ) z++;
    if( z[0]==0 ) return;   /* Stop searching at "--" */
    if( fossil_strcmp(z, "args")==0 ) break;