SQLite

Check-in [e02f255602]
Login

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

Overview
Comment:Fix a case in os_unix.c where two structures that might have uninitialized padding bytes are compared using memcmp().
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e02f25560216c7c96c5e1c7e71a8531650b3a96f
User & Date: drh 2010-01-05 00:14:49.000
Context
2010-01-05
03:30
In the debugging memory allocator, initialize new memory allocations to pseudo-randomness in an effort to find problems with memcmp() of structures that have uninitialized pad bytes. (check-in: 6462817b2f user: drh tags: trunk)
00:14
Fix a case in os_unix.c where two structures that might have uninitialized padding bytes are compared using memcmp(). (check-in: e02f255602 user: drh tags: trunk)
2010-01-04
13:30
Version 3.6.22 Release Candidate 1 (check-in: 9d8ab0f1f5 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813




3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
  ** For this reason, if an error occurs in the stat() call here, it is
  ** ignored and -1 is returned. The caller will try to open a new file
  ** descriptor on the same path, fail, and return an error to SQLite.
  **
  ** Even if a subsequent open() call does succeed, the consequences of
  ** not searching for a resusable file descriptor are not dire.  */
  if( 0==stat(zPath, &sStat) ){
    struct unixOpenCnt *pO;
    struct unixFileId id;
    id.dev = sStat.st_dev;
    id.ino = sStat.st_ino;

    unixEnterMutex();
    for(pO=openList; pO && memcmp(&id, &pO->fileId, sizeof(id)); pO=pO->pNext);




    if( pO ){
      UnixUnusedFd **pp;
      for(pp=&pO->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
      pUnused = *pp;
      if( pUnused ){
        *pp = pUnused->pNext;
      }
    }
    unixLeaveMutex();
  }







|
<
<
<


|
>
>
>
>
|

|







3800
3801
3802
3803
3804
3805
3806
3807



3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
  ** For this reason, if an error occurs in the stat() call here, it is
  ** ignored and -1 is returned. The caller will try to open a new file
  ** descriptor on the same path, fail, and return an error to SQLite.
  **
  ** Even if a subsequent open() call does succeed, the consequences of
  ** not searching for a resusable file descriptor are not dire.  */
  if( 0==stat(zPath, &sStat) ){
    struct unixOpenCnt *pOpen;




    unixEnterMutex();
    pOpen = openList;
    while( pOpen && (pOpen->fileId.dev!=sStat.st_dev
                     || pOpen->fileId.ino!=sStat.st_ino) ){
       pOpen = pOpen->pNext;
    }
    if( pOpen ){
      UnixUnusedFd **pp;
      for(pp=&pOpen->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext));
      pUnused = *pp;
      if( pUnused ){
        *pp = pUnused->pNext;
      }
    }
    unixLeaveMutex();
  }
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683

#ifdef LOCKPROXYDIR
  len = strlcpy(lPath, LOCKPROXYDIR, maxLen);
#else
# ifdef _CS_DARWIN_USER_TEMP_DIR
  {
    confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen);
    len = strlcat(lPath, "sqliteplocks", maxLen);
    if( mkdir(lPath, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){
      /* if mkdir fails, handle as lock file creation failure */
#  ifdef SQLITE_DEBUG
      int err = errno;
      if( err!=EEXIST ){
        fprintf(stderr, "proxyGetLockPath: mkdir(%s,0%o) error %d %s\n", lPath,
                SQLITE_DEFAULT_PROXYDIR_PERMISSIONS, err, strerror(err));







|







4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684

#ifdef LOCKPROXYDIR
  len = strlcpy(lPath, LOCKPROXYDIR, maxLen);
#else
# ifdef _CS_DARWIN_USER_TEMP_DIR
  {
    confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen);
    len = strlcat(lPath, "sqliteplocks", maxLen);    
    if( mkdir(lPath, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){
      /* if mkdir fails, handle as lock file creation failure */
#  ifdef SQLITE_DEBUG
      int err = errno;
      if( err!=EEXIST ){
        fprintf(stderr, "proxyGetLockPath: mkdir(%s,0%o) error %d %s\n", lPath,
                SQLITE_DEFAULT_PROXYDIR_PERMISSIONS, err, strerror(err));