/ Check-in [d0a86860]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Make sure filenames handed to the VFS by the fake_big_file test procedure are double-zero terminated.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d0a868607e8f46941ece9f9d7b8ba220a7fb4e2b
User & Date: drh 2012-01-11 00:38:51
Context
2012-01-11
01:01
Prevent winOpenSharedMemory from masking the real return code from its call to winOpen. Also, add asserts to check the double-zero termination of database file names. check-in: 93a65776 user: mistachkin tags: trunk
00:38
Make sure filenames handed to the VFS by the fake_big_file test procedure are double-zero terminated. check-in: d0a86860 user: drh tags: trunk
2012-01-10
23:18
Only require double-zero terminators on database filenames, not any every files supplied to the xOpen method. This backs out [2544f233f1]. Also refactor the fillInUnixFile() routine in os_unix.c to reduce the number of parameters. check-in: cb774b26 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test2.c.

   533    533     const char **argv      /* Text of each argument */
   534    534   ){
   535    535     sqlite3_vfs *pVfs;
   536    536     sqlite3_file *fd = 0;
   537    537     int rc;
   538    538     int n;
   539    539     i64 offset;
          540  +  char *zFile;
          541  +  int nFile;
   540    542     if( argc!=3 ){
   541    543       Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
   542    544          " N-MEGABYTES FILE\"", 0);
   543    545       return TCL_ERROR;
   544    546     }
   545    547     if( Tcl_GetInt(interp, argv[1], &n) ) return TCL_ERROR;
   546    548   
   547    549     pVfs = sqlite3_vfs_find(0);
   548         -  rc = sqlite3OsOpenMalloc(pVfs, argv[2], &fd, 
          550  +  nFile = strlen(argv[2]);
          551  +  zFile = sqlite3_malloc( nFile+2 );
          552  +  if( zFile==0 ) return TCL_ERROR;
          553  +  memcpy(zFile, argv[2], nFile+1);
          554  +  zFile[nFile+1] = 0;
          555  +  rc = sqlite3OsOpenMalloc(pVfs, zFile, &fd, 
   549    556         (SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB), 0
   550    557     );
   551    558     if( rc ){
   552    559       Tcl_AppendResult(interp, "open failed: ", errorName(rc), 0);
          560  +    sqlite3_free(zFile);
   553    561       return TCL_ERROR;
   554    562     }
   555    563     offset = n;
   556    564     offset *= 1024*1024;
   557    565     rc = sqlite3OsWrite(fd, "Hello, World!", 14, offset);
   558    566     sqlite3OsCloseFree(fd);
          567  +  sqlite3_free(zFile);
   559    568     if( rc ){
   560    569       Tcl_AppendResult(interp, "write failed: ", errorName(rc), 0);
   561    570       return TCL_ERROR;
   562    571     }
   563    572     return TCL_OK;
   564    573   }
   565    574   #endif