diff options
author | sb <sb@openoffice.org> | 2009-10-20 15:26:49 +0200 |
---|---|---|
committer | sb <sb@openoffice.org> | 2009-10-20 15:26:49 +0200 |
commit | 28e6a67615184ee13a032e662d17d535e4822fa7 (patch) | |
tree | 4172dd3a0c9a9597f1e839e5e704e2fb0fadfe93 /sal | |
parent | 4e9db26ac86b8e140cc90094d0ab38cfed964e15 (diff) |
#i106074# silence extra warnings with GCC Fortify Source (patch by cmc)
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/process.c | 50 | ||||
-rw-r--r-- | sal/osl/unx/profile.c | 12 |
2 files changed, 32 insertions, 30 deletions
diff --git a/sal/osl/unx/process.c b/sal/osl/unx/process.c index 7966651bed86..6745c8ba543c 100644 --- a/sal/osl/unx/process.c +++ b/sal/osl/unx/process.c @@ -432,9 +432,8 @@ oslSocket osl_receiveResourcePipe(oslPipe pPipe) static void ChildStatusProc(void *pData) { int i; -/* int first = 0;*/ - pid_t pid; -/* int status;*/ + pid_t pid = -1; + int status = 0; int channel[2]; ProcessData data; ProcessData *pdata; @@ -447,23 +446,26 @@ static void ChildStatusProc(void *pData) in our child process */ memcpy(&data, pData, sizeof(data)); - socketpair(AF_UNIX, SOCK_STREAM, 0, channel); + if (socketpair(AF_UNIX, SOCK_STREAM, 0, channel) == -1) + status = errno; fcntl(channel[0], F_SETFD, FD_CLOEXEC); fcntl(channel[1], F_SETFD, FD_CLOEXEC); /* Create redirected IO pipes */ + if ( status == 0 && data.m_pInputWrite ) + if (pipe( stdInput ) == -1) + status = errno; - if ( data.m_pInputWrite ) - pipe( stdInput ); + if ( status == 0 && data.m_pOutputRead ) + if (pipe( stdOutput ) == -1) + status = errno; - if ( data.m_pOutputRead ) - pipe( stdOutput ); + if ( status == 0 && data.m_pErrorRead ) + if (pipe( stdError ) == -1) + status = errno; - if ( data.m_pErrorRead ) - pipe( stdError ); - - if ((pid = fork()) == 0) + if ( (status == 0) && ((pid = fork()) == 0) ) { /* Child */ if (channel[0] != -1) close(channel[0]); @@ -481,12 +483,12 @@ static void ChildStatusProc(void *pData) #endif } - if ((data.m_uid == (uid_t)-1) || ((data.m_uid == getuid()) && (data.m_gid == getgid()))) + int chstatus = 0; + if (data.m_pszDir) + chstatus = chdir(data.m_pszDir); + if (chstatus == 0 && ((data.m_uid == (uid_t)-1) || ((data.m_uid == getuid()) && (data.m_gid == getgid())))) { - if (data.m_pszDir) - chdir(data.m_pszDir); - for (i = 0; data.m_pszEnv[i] != NULL; i++) putenv(data.m_pszEnv[i]); @@ -532,7 +534,9 @@ static void ChildStatusProc(void *pData) OSL_TRACE("ChildStatusProc : starting '%s' failed",data.m_pszArgs[0]); /* if we reach here, something went wrong */ - write(channel[1], &errno, sizeof(errno)); + sal_Int32 nWrote = write(channel[1], &errno, sizeof(errno)); + if (nWrote != sizeof(errno)) + OSL_TRACE("sendFdPipe : sending failed (%s)",strerror(errno)); if (channel[1] != -1) close(channel[1]); @@ -540,8 +544,6 @@ static void ChildStatusProc(void *pData) } else { /* Parent */ - int status; - if (channel[1] != -1) close(channel[1]); /* Close unused pipe ends */ @@ -549,15 +551,17 @@ static void ChildStatusProc(void *pData) if (stdOutput[1] != -1) close( stdOutput[1] ); if (stdError[1] != -1) close( stdError[1] ); - while (((i = read(channel[0], &status, sizeof(status))) < 0)) + if (pid > 0) { - if (errno != EINTR) - break; + while (((i = read(channel[0], &status, sizeof(status))) < 0)) + { + if (errno != EINTR) + break; + } } if (channel[0] != -1) close(channel[0]); - if ((pid > 0) && (i == 0)) { pid_t child_pid; diff --git a/sal/osl/unx/profile.c b/sal/osl/unx/profile.c index a01d292e23b6..a0ea4c59ffdd 100644 --- a/sal/osl/unx/profile.c +++ b/sal/osl/unx/profile.c @@ -263,12 +263,9 @@ static oslProfile SAL_CALL osl_psz_openProfile(const sal_Char *pszProfileName, o pProfile->m_Stamp = OslProfile_getFileStamp(pFile); bRet=loadProfile(pFile, pProfile); + bRet &= realpath(pszProfileName, pProfile->m_FileName) != NULL; OSL_ASSERT(bRet); - /* #109261# using osl profiles is deprecated */ - /* OSL_VERIFY(NULL != realpath(pszProfileName, pProfile->m_FileName)); */ - realpath(pszProfileName, pProfile->m_FileName); - if (pProfile->m_pFile == NULL) closeFileImpl(pFile,pProfile->m_Flags); @@ -1338,6 +1335,7 @@ static osl_TStamp closeFileImpl(osl_TFile* pFile, oslProfileOption Flags) static sal_Bool OslProfile_rewindFile(osl_TFile* pFile, sal_Bool bTruncate) { + sal_Bool bRet = sal_True; #ifdef TRACE_OSL_PROFILE OSL_TRACE("In osl_OslProfile_rewindFile\n"); #endif @@ -1349,14 +1347,14 @@ static sal_Bool OslProfile_rewindFile(osl_TFile* pFile, sal_Bool bTruncate) #ifdef DEBUG_OSL_PROFILE OSL_TRACE("rewinding\n"); #endif - lseek(pFile->m_Handle, SEEK_SET, 0L); + bRet = (lseek(pFile->m_Handle, SEEK_SET, 0L) == 0L); if (bTruncate) { #ifdef DEBUG_OSL_PROFILE OSL_TRACE("truncating\n"); #endif - ftruncate(pFile->m_Handle, 0L); + bRet &= (ftruncate(pFile->m_Handle, 0L) == 0); } } @@ -1364,7 +1362,7 @@ static sal_Bool OslProfile_rewindFile(osl_TFile* pFile, sal_Bool bTruncate) #ifdef TRACE_OSL_PROFILE OSL_TRACE("Out osl_OslProfile_rewindFile [ok]\n"); #endif - return (sal_True); + return bRet; } |