/ Check-in [ee886600]
Login

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

Overview
Comment:Fix a bug in test module test_fs.c causing a segfault on OpenBSD.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: ee886600297c2a03d9d1d10db88d3d107b48e5d4de5e5d91b0ab16cc7c447ede
User & Date: dan 2019-04-15 19:17:50
Context
2019-04-16
10:51
Avoid a sanitizer error in test1.c. Have releasetest.tcl/wapptest.tcl create a file called "makecommand.sh" that can be used to rerun a test from the command line. check-in: 4de4480f user: dan tags: trunk
2019-04-15
19:17
Fix a bug in test module test_fs.c causing a segfault on OpenBSD. check-in: ee886600 user: dan tags: trunk
15:41
Fix a problem with the user-auth extension and deserializing in-memory databases. check-in: 09fa0b3c user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_fs.c.

   125    125   };
   126    126   
   127    127   struct FsdirCsr {
   128    128     sqlite3_vtab_cursor base;
   129    129     char *zDir;                     /* Buffer containing directory scanned */
   130    130     DIR *pDir;                      /* Open directory */
   131    131     sqlite3_int64 iRowid;
   132         -  struct DIRENT entry;            /* Current entry */
          132  +  struct DIRENT *pEntry;
   133    133   };
   134    134   
   135    135   /*
   136    136   ** This function is the implementation of both the xConnect and xCreate
   137    137   ** methods of the fsdir virtual table.
   138    138   **
   139    139   ** The argv[] array contains the following:
................................................................................
   232    232   /*
   233    233   ** Skip the cursor to the next entry.
   234    234   */
   235    235   static int fsdirNext(sqlite3_vtab_cursor *cur){
   236    236     FsdirCsr *pCsr = (FsdirCsr*)cur;
   237    237   
   238    238     if( pCsr->pDir ){
   239         -    struct DIRENT *pRes = 0;
   240         -    pRes = readdir(pCsr->pDir);
   241         -    if( pRes!=0 ){
   242         -      memcpy(&pCsr->entry, pRes, sizeof(struct DIRENT));
   243         -    }
   244         -    if( pRes==0 ){
          239  +    pCsr->pEntry = readdir(pCsr->pDir);
          240  +    if( pCsr->pEntry==0 ){
   245    241         closedir(pCsr->pDir);
   246    242         pCsr->pDir = 0;
   247    243       }
   248    244       pCsr->iRowid++;
   249    245     }
   250    246   
   251    247     return SQLITE_OK;
................................................................................
   300    296     FsdirCsr *pCsr = (FsdirCsr*)cur;
   301    297     switch( i ){
   302    298       case 0: /* dir */
   303    299         sqlite3_result_text(ctx, pCsr->zDir, -1, SQLITE_STATIC);
   304    300         break;
   305    301   
   306    302       case 1: /* name */
   307         -      sqlite3_result_text(ctx, pCsr->entry.d_name, -1, SQLITE_TRANSIENT);
          303  +      sqlite3_result_text(ctx, pCsr->pEntry->d_name, -1, SQLITE_TRANSIENT);
   308    304         break;
   309    305   
   310    306       default:
   311    307         assert( 0 );
   312    308     }
   313    309   
   314    310     return SQLITE_OK;