/ Check-in [c1691004]
Login

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

Overview
Comment:Handle failures of getcwd() without segfaulting. Ticket #1274. (CVS 2490)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c1691004d6d81b683a4ca5b1723c0de8b9b4e376
User & Date: drh 2005-06-06 15:06:39
Context
2005-06-06
15:32
Do not allow parameters in VIEW definitions. Ticket #1270. (CVS 2492) check-in: 0d46289f user: drh tags: trunk
15:06
Handle failures of getcwd() without segfaulting. Ticket #1274. (CVS 2490) check-in: c1691004 user: drh tags: trunk
14:45
Fix a bug in the malloc2 tests introduced by checkin (2473). (CVS 2489) check-in: fafaa18e user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  1287   1287   */
  1288   1288   char *sqlite3OsFullPathname(const char *zRelative){
  1289   1289     char *zFull = 0;
  1290   1290     if( zRelative[0]=='/' ){
  1291   1291       sqlite3SetString(&zFull, zRelative, (char*)0);
  1292   1292     }else{
  1293   1293       char zBuf[5000];
         1294  +    zBuf[0] = 0;
  1294   1295       sqlite3SetString(&zFull, getcwd(zBuf, sizeof(zBuf)), "/", zRelative,
  1295   1296                       (char*)0);
  1296   1297     }
  1297   1298     return zFull;
  1298   1299   }
  1299   1300   
  1300   1301   /*

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.384 2005/05/25 10:45:10 danielk1977 Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.385 2005/06/06 15:06:39 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** These #defines should enable >2GB file support on Posix if the
    21     21   ** underlying operating system supports it.  If the OS lacks
................................................................................
  1336   1336   #endif
  1337   1337   void sqlite3FreeX(void*);
  1338   1338   void *sqlite3MallocX(int);
  1339   1339   char *sqlite3MPrintf(const char*, ...);
  1340   1340   char *sqlite3VMPrintf(const char*, va_list);
  1341   1341   void sqlite3DebugPrintf(const char*, ...);
  1342   1342   void *sqlite3TextToPtr(const char*);
  1343         -void sqlite3SetString(char **, const char *, ...);
         1343  +void sqlite3SetString(char **, ...);
  1344   1344   void sqlite3ErrorMsg(Parse*, const char*, ...);
  1345   1345   void sqlite3Dequote(char*);
  1346   1346   int sqlite3KeywordCode(const char*, int);
  1347   1347   int sqlite3RunParser(Parse*, const char*, char **);
  1348   1348   void sqlite3FinishCoding(Parse*);
  1349   1349   Expr *sqlite3Expr(int, Expr*, Expr*, const Token*);
  1350   1350   Expr *sqlite3RegisterExpr(Parse*,Token*);

Changes to src/util.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Utility functions used throughout sqlite.
    13     13   **
    14     14   ** This file contains functions for allocating memory, comparing
    15     15   ** strings, and stuff like that.
    16     16   **
    17         -** $Id: util.c,v 1.135 2005/05/23 13:00:58 danielk1977 Exp $
           17  +** $Id: util.c,v 1.136 2005/06/06 15:06:39 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include <stdarg.h>
    21     21   #include <ctype.h>
    22     22   
    23     23   #if SQLITE_MEMDEBUG>2 && defined(__GLIBC__)
    24     24   #include <execinfo.h>
................................................................................
   343    343   /*
   344    344   ** Create a string from the 2nd and subsequent arguments (up to the
   345    345   ** first NULL argument), store the string in memory obtained from
   346    346   ** sqliteMalloc() and make the pointer indicated by the 1st argument
   347    347   ** point to that string.  The 1st argument must either be NULL or 
   348    348   ** point to memory obtained from sqliteMalloc().
   349    349   */
   350         -void sqlite3SetString(char **pz, const char *zFirst, ...){
          350  +void sqlite3SetString(char **pz, ...){
   351    351     va_list ap;
   352    352     int nByte;
   353    353     const char *z;
   354    354     char *zResult;
   355    355   
   356    356     if( pz==0 ) return;
   357         -  nByte = strlen(zFirst) + 1;
   358         -  va_start(ap, zFirst);
          357  +  nByte = 1;
          358  +  va_start(ap, pz);
   359    359     while( (z = va_arg(ap, const char*))!=0 ){
   360    360       nByte += strlen(z);
   361    361     }
   362    362     va_end(ap);
   363    363     sqliteFree(*pz);
   364    364     *pz = zResult = sqliteMallocRaw( nByte );
   365    365     if( zResult==0 ){
   366    366       return;
   367    367     }
   368         -  strcpy(zResult, zFirst);
   369         -  zResult += strlen(zResult);
   370         -  va_start(ap, zFirst);
          368  +  *zResult = 0;
          369  +  va_start(ap, pz);
   371    370     while( (z = va_arg(ap, const char*))!=0 ){
   372    371       strcpy(zResult, z);
   373    372       zResult += strlen(zResult);
   374    373     }
   375    374     va_end(ap);
   376    375   #ifdef SQLITE_DEBUG
   377    376   #if SQLITE_DEBUG>1