diff --git a/cde/lib/tt/bin/ttdbserverd/dm_server.C b/cde/lib/tt/bin/ttdbserverd/dm_server.C index 84fb23233..d45593ec8 100644 --- a/cde/lib/tt/bin/ttdbserverd/dm_server.C +++ b/cde/lib/tt/bin/ttdbserverd/dm_server.C @@ -1561,7 +1561,10 @@ _tt_transaction_1(_Tt_transaction_args* args, SVCXPRT * /* transp */) return _tt_transaction_error(fd); } /* Turn on close-on-exec */ - fcntl(fd, F_SETFD, 1); + if(fcntl(fd, F_SETFD, 1) == -1) { + res.iserrno = DM_WRITE_FAILED; + return _tt_transaction_error(fd); + } /* reset to beginning of file */ off_t offset; diff --git a/cde/lib/tt/bin/ttsession/mp_server.C b/cde/lib/tt/bin/ttsession/mp_server.C index c0ea10c0c..760c29b6f 100644 --- a/cde/lib/tt/bin/ttsession/mp_server.C +++ b/cde/lib/tt/bin/ttsession/mp_server.C @@ -251,12 +251,12 @@ int main(int argc, char **argv) _tt_syslog( errstr, LOG_ERR, "%m" ); exit(1); } - cargv[i] = '\0'; + cargv[i] = NULL; // if no program given then use $SHELL if (! cargv[0]) { cargv[0] = getenv("SHELL"); - cargv[1] = '\0'; + cargv[1] = NULL; } cmd = cargv[0]; background_mode = 0; diff --git a/cde/lib/tt/lib/api/c/api_pattern.C b/cde/lib/tt/lib/api/c/api_pattern.C index 88d7be158..a53c3d481 100644 --- a/cde/lib/tt/lib/api/c/api_pattern.C +++ b/cde/lib/tt/lib/api/c/api_pattern.C @@ -1540,7 +1540,11 @@ _tt_session_types_load(const char *filename) if (-1==(fd=open(filename, O_RDONLY))) { return TT_ERR_FILE; } - fcntl(fd, F_SETFD, 1); /* Close on exec */ + /* Close on exec */ + if (-1==fcntl(fd, F_SETFD, 1)) { + close(fd); + return TT_ERR_FILE; + } if (-1==fstat(fd, &typefile_stat)) { close(fd); diff --git a/cde/lib/tt/lib/mp/mp_auth.C b/cde/lib/tt/lib/mp/mp_auth.C index b44369d39..b847ba4f0 100644 --- a/cde/lib/tt/lib/mp/mp_auth.C +++ b/cde/lib/tt/lib/mp/mp_auth.C @@ -173,6 +173,7 @@ read_auth_entries(FILE *fp, _tt_AuthFileEntryList **headp) _tt_syslog(0, LOG_ERR, "%s: memory error. New entry not written.\n", funcname); + free(entry); return TT_ERR_NOMEM; } diff --git a/cde/lib/tt/lib/mp/mp_stream_socket.C b/cde/lib/tt/lib/mp/mp_stream_socket.C index 8d08a0de9..c0cda276f 100644 --- a/cde/lib/tt/lib/mp/mp_stream_socket.C +++ b/cde/lib/tt/lib/mp/mp_stream_socket.C @@ -88,6 +88,8 @@ _Tt_stream_socket() _sock = -1; _hostaddr.sin_port = 0; _hostaddr.sin_family = 0; + memset(&_hostaddr.sin_addr, 0, sizeof(struct in_addr)); + } _Tt_stream_socket:: @@ -557,7 +559,7 @@ recv(char *msg, int msglen) { int rval; - if (_msgsock == -1 && accept() == -1) { + if (_msgsock == -1 || accept() == -1) { return(-1); } diff --git a/cde/lib/tt/lib/tttk/tttk.C b/cde/lib/tt/lib/tttk/tttk.C index 1f0c2b8fe..970c9fcaa 100644 --- a/cde/lib/tt/lib/tttk/tttk.C +++ b/cde/lib/tt/lib/tttk/tttk.C @@ -271,6 +271,7 @@ ttdt_session_join( if (join) { status = tt_session_join( sessid ); if (status != TT_OK) { + free(pats); return (Tt_pattern *)tt_error_pointer( status ); } } diff --git a/cde/lib/tt/lib/util/tt_audit.C b/cde/lib/tt/lib/util/tt_audit.C index 426ba42eb..a16c41fcd 100644 --- a/cde/lib/tt/lib/util/tt_audit.C +++ b/cde/lib/tt/lib/util/tt_audit.C @@ -533,6 +533,7 @@ entry(const char *argskey, _Tt_entry_pt func, ...) _tt_syslog(0, LOG_ERR, "_Tt_audit::entry(): ARG_INTEGER: func==%s", _tt_enumname(func)); + va_end(ap); return TT_ERR_INTERNAL; } } break; diff --git a/cde/lib/tt/lib/util/tt_log.C b/cde/lib/tt/lib/util/tt_log.C index 81c2d4c52..58a49380a 100644 --- a/cde/lib/tt/lib/util/tt_log.C +++ b/cde/lib/tt/lib/util/tt_log.C @@ -76,7 +76,10 @@ _tt_log_error(int errno, int line, char *file, char *msg) if (fl == (FILE *)0) { return; } - fcntl(fileno(fl), F_SETFD, 1); /* Close on exec */ + /* Close on exec */ + if(fcntl(fileno(fl), F_SETFD, 1) == -1) { + return; + } time(&clock); timestamp = _XCtime(&clock, ctime_buf); diff --git a/cde/lib/tt/lib/util/tt_trace.h b/cde/lib/tt/lib/util/tt_trace.h index 2a049e95b..084cb4127 100644 --- a/cde/lib/tt/lib/util/tt_trace.h +++ b/cde/lib/tt/lib/util/tt_trace.h @@ -102,7 +102,7 @@ class _Tt_trace_stream; class _Tt_trace : public _Tt_allocated { public: // suppresses "used but not set" warnings - _Tt_trace() {}; + _Tt_trace() : _funcname(TT_X_SESSION), _tracing(0) {}; // Initializes tracing (if necessary) static int init( int even_if_no_envariable = 0 diff --git a/cde/lib/tt/mini_isam/isfcb.c b/cde/lib/tt/mini_isam/isfcb.c index 8d58957ab..cf810b4e9 100644 --- a/cde/lib/tt/mini_isam/isfcb.c +++ b/cde/lib/tt/mini_isam/isfcb.c @@ -649,6 +649,11 @@ _create_datfile(isfname) fd = open (namebuf, O_CREAT | O_EXCL | O_RDWR, 0666); if (fd > -1) { fcntl(fd, F_SETFD, 1); /* Close on exec */ + /* Close on exec */ + if(fcntl(fd, F_SETFD, 1) == -1) { + close(fd); + return(-1); + } } return (fd); } @@ -671,7 +676,11 @@ _create_indfile(isfname) fd = open (namebuf, O_CREAT | O_EXCL | O_RDWR, 0666); if (fd > -1) { - fcntl(fd, F_SETFD, 1); /* Close on exec */ + /* Close on exec */ + if(fcntl(fd, F_SETFD, 1) == -1) { + close(fd); + return(-1); + } } return (fd); } @@ -694,7 +703,11 @@ _create_varfile(isfname) fd = open (namebuf, O_CREAT | O_EXCL | O_RDWR, 0666); if (fd > -1) { - fcntl(fd, F_SETFD, 1); /* Close on exec */ + /* Close on exec */ + if(fcntl(fd, F_SETFD, 1) == -1) { + close(fd); + return(-1); + } } return (fd); } @@ -774,14 +787,22 @@ _open_datfile(isfname, rdonly) if ((ret = open (namebuf, O_RDWR)) != -1) { *rdonly = FALSE; - fcntl(ret, F_SETFD, 1); /* Close on exec */ - return (ret); + /* Close on exec */ + if(fcntl(ret, F_SETFD, 1) == -1) { + close(ret); + ret = -1; + } + return (ret); } *rdonly = TRUE; ret = open (namebuf, O_RDONLY); if (ret > -1) { - fcntl(ret, F_SETFD, 1); /* Close on exec */ + /* Close on exec */ + if(fcntl(ret, F_SETFD, 1) == -1) { + close(ret); + return(-1); + } } return (ret); } @@ -805,7 +826,11 @@ _open_indfile(isfname, rdonly) fd = open (namebuf, (rdonly==TRUE)?O_RDONLY:O_RDWR); if (fd > -1) { - fcntl(fd, F_SETFD, 1); /* Close on exec */ + /* Close on exec */ + if(fcntl(fd, F_SETFD, 1) == -1) { + close(fd); + return(-1); + } } return (fd); } @@ -829,7 +854,11 @@ _open_varfile(isfname, rdonly) fd = open (namebuf, (rdonly==TRUE)?O_RDONLY:O_RDWR); if (fd > -1) { - fcntl(fd, F_SETFD, 1); /* Close on exec */ + /* Close on exec */ + if(fcntl(fd, F_SETFD, 1) == -1) { + close(fd); + return(-1); + } } return (fd); } @@ -882,7 +911,11 @@ _open2_indfile(fcb) fcb->indfd = open(namebuf, openmode, buf.st_mode); if (fcb->indfd > -1) { - fcntl(fcb->indfd, F_SETFD, 1); /* Close on exec */ + /* Close on exec */ + if(fcntl(fcb->indfd, F_SETFD, 1) == -1) { + close(fcb->indfd); + fcb->indfd = -1; + } } if(fcb->indfd == -1 && (openmode & O_CREAT)) { diff --git a/cde/lib/tt/mini_isam/isrepair.c b/cde/lib/tt/mini_isam/isrepair.c index e1cc4ed90..531a47590 100644 --- a/cde/lib/tt/mini_isam/isrepair.c +++ b/cde/lib/tt/mini_isam/isrepair.c @@ -112,21 +112,30 @@ isrepair(isfname, verbose) _makedat_isfname(namebuf); datfd = open(namebuf, O_RDONLY); if (datfd > -1) { - fcntl(datfd, F_SETFD, 1); + if(fcntl(datfd, F_SETFD, 1) == -1) { + close(datfd); + datfd = -1; + } } (void)strcpy(namebuf, isfname); _makeind_isfname(namebuf); indfd = open(namebuf, O_RDONLY); if (indfd > -1) { - fcntl(indfd, F_SETFD, 1); + if(fcntl(indfd, F_SETFD, 1) == -1) { + close(indfd); + indfd = -1; + } } (void)strcpy(namebuf, isfname); _makevar_isfname(namebuf); varfd = open(namebuf, O_RDONLY); if (varfd > -1) { - fcntl(varfd, F_SETFD, 1); + if(fcntl(varfd, F_SETFD, 1) == -1) { + close(varfd); + varfd = -1; + } } (void)print("Reading control page from %s.rec file...\n", diff --git a/cde/lib/tt/slib/mp_rpc_server.C b/cde/lib/tt/slib/mp_rpc_server.C index 4df567d44..c134bc5e4 100644 --- a/cde/lib/tt/slib/mp_rpc_server.C +++ b/cde/lib/tt/slib/mp_rpc_server.C @@ -391,7 +391,10 @@ gettransient(int proto, int vers, int *sockp) addr.sin_port = htons(0); addr.sin_family = AF_INET; len = sizeof(addr); - bind(s, (sockaddr *)&addr, len); + if(bind(s, (sockaddr *)&addr, len) == -1) { + _tt_syslog(0, LOG_ERR, "bind(): %m"); + return(0); + } #if defined (_AIX) && (OSMAJORVERSION==4) && (OSMINORVERSION==2) if (getsockname(s, (sockaddr *)&addr, (size_t *)&len) < 0) { #else