diff options
author | drh <drh@noemail.net> | 2010-01-05 00:14:49 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-01-05 00:14:49 +0000 |
commit | 9061ad10bc3fd47ee82c86d4e9448d1138c20787 (patch) | |
tree | ba6279efee57500ce680d6ab6254a759210a1ba5 /src/os_unix.c | |
parent | 6070f7eed41a8b26e66f668318190f58f532ae54 (diff) | |
download | sqlite-9061ad10bc3fd47ee82c86d4e9448d1138c20787.tar.gz sqlite-9061ad10bc3fd47ee82c86d4e9448d1138c20787.zip |
Fix a case in os_unix.c where two structures that might have uninitialized
padding bytes are compared using memcmp().
FossilOrigin-Name: e02f25560216c7c96c5e1c7e71a8531650b3a96f
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index d7a9d8ec5..4dd451fed 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3804,16 +3804,17 @@ static UnixUnusedFd *findReusableFd(const char *zPath, int flags){ ** 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; + struct unixOpenCnt *pOpen; unixEnterMutex(); - for(pO=openList; pO && memcmp(&id, &pO->fileId, sizeof(id)); pO=pO->pNext); - if( pO ){ + 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=&pO->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext)); + for(pp=&pOpen->pUnused; *pp && (*pp)->flags!=flags; pp=&((*pp)->pNext)); pUnused = *pp; if( pUnused ){ *pp = pUnused->pNext; @@ -4673,7 +4674,7 @@ static int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){ # ifdef _CS_DARWIN_USER_TEMP_DIR { confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen); - len = strlcat(lPath, "sqliteplocks", 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 |