libtt: Further coverity fixes

This commit is contained in:
Peter Howkins
2018-04-20 22:57:47 +01:00
parent f905d25392
commit 22071fd62a
12 changed files with 79 additions and 19 deletions

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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 );
}
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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