/ Check-in [f015a387]
Login

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

Overview
Comment:Use the specified buffer length, not the maximum buffer length in unixFullPathname() and related functions. (CVS 4595)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f015a38771d98996366d66787b9b066f9ef5e248
User & Date: drh 2007-12-06 13:26:21
Context
2007-12-06
17:41
Fix a leaking database connection in the vacuum2 test script. Ticket #2827. (CVS 4596) check-in: f29deb5f user: drh tags: trunk
13:26
Use the specified buffer length, not the maximum buffer length in unixFullPathname() and related functions. (CVS 4595) check-in: f015a387 user: drh tags: trunk
02:42
Continuing work on the C/C++ interface requirements that appears as comments in sqlite.h.in. (CVS 4594) check-in: 2130e712 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  2508   2508       if( azDirs[i]==0 ) continue;
  2509   2509       if( stat(azDirs[i], &buf) ) continue;
  2510   2510       if( !S_ISDIR(buf.st_mode) ) continue;
  2511   2511       if( access(azDirs[i], 07) ) continue;
  2512   2512       zDir = azDirs[i];
  2513   2513       break;
  2514   2514     }
         2515  +  if( strlen(zDir) - sizeof(SQLITE_TEMP_FILE_PREFIX) - 17 <=0 ){
         2516  +    return SQLITE_ERROR;
         2517  +  }
  2515   2518     do{
  2516   2519       assert( pVfs->mxPathname==MAX_PATHNAME );
  2517         -    assert( nBuf>=MAX_PATHNAME );
  2518         -    sqlite3_snprintf(MAX_PATHNAME-17, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX, zDir);
         2520  +    sqlite3_snprintf(nBuf-17, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX, zDir);
  2519   2521       j = strlen(zBuf);
  2520   2522       sqlite3Randomness(15, &zBuf[j]);
  2521   2523       for(i=0; i<15; i++, j++){
  2522   2524         zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
  2523   2525       }
  2524   2526       zBuf[j] = 0;
  2525   2527     }while( access(zBuf,0)==0 );
................................................................................
  2547   2549     ** using the io-error infrastructure to test that SQLite handles this
  2548   2550     ** function failing. This function could fail if, for example, the
  2549   2551     ** current working directly has been unlinked.
  2550   2552     */
  2551   2553     SimulateIOError( return SQLITE_ERROR );
  2552   2554   
  2553   2555     assert( pVfs->mxPathname==MAX_PATHNAME );
  2554         -  zOut[MAX_PATHNAME-1] = '\0';
         2556  +  zOut[nOut-1] = '\0';
  2555   2557     if( zPath[0]=='/' ){
  2556         -    sqlite3_snprintf(MAX_PATHNAME, zOut, "%s", zPath);
         2558  +    sqlite3_snprintf(nOut, zOut, "%s", zPath);
  2557   2559     }else{
  2558   2560       int nCwd;
  2559         -    if( getcwd(zOut, MAX_PATHNAME-1)==0 ){
         2561  +    if( getcwd(zOut, nOut-1)==0 ){
  2560   2562         return SQLITE_CANTOPEN;
  2561   2563       }
  2562   2564       nCwd = strlen(zOut);
  2563         -    sqlite3_snprintf(MAX_PATHNAME-nCwd, &zOut[nCwd], "/%s", zPath);
         2565  +    sqlite3_snprintf(nOut-nCwd, &zOut[nCwd], "/%s", zPath);
  2564   2566     }
  2565   2567     return SQLITE_OK;
  2566   2568   
  2567   2569   #if 0
  2568   2570     /*
  2569   2571     ** Remove "/./" path elements and convert "/A/./" path elements
  2570   2572     ** to just "/".

Changes to src/os_win.c.

  1300   1300         free(zUtf8);
  1301   1301       }else{
  1302   1302         return SQLITE_NOMEM;
  1303   1303       }
  1304   1304     }
  1305   1305     for(i=strlen(zTempPath); i>0 && zTempPath[i-1]=='\\'; i--){}
  1306   1306     zTempPath[i] = 0;
  1307         -  sqlite3_snprintf(pVfs->mxPathname-30, zBuf,
         1307  +  sqlite3_snprintf(nBuf-30, zBuf,
  1308   1308                      "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath);
  1309   1309     j = strlen(zBuf);
  1310   1310     sqlite3Randomness(20, &zBuf[j]);
  1311   1311     for(i=0; i<20; i++, j++){
  1312   1312       zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ];
  1313   1313     }
  1314   1314     zBuf[j] = 0;