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;
_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;
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);
_tt_syslog(0, LOG_ERR,
"%s: memory error. New entry not written.\n",
funcname);
+ free(entry);
return TT_ERR_NOMEM;
}
_sock = -1;
_hostaddr.sin_port = 0;
_hostaddr.sin_family = 0;
+ memset(&_hostaddr.sin_addr, 0, sizeof(struct in_addr));
+
}
_Tt_stream_socket::
{
int rval;
- if (_msgsock == -1 && accept() == -1) {
+ if (_msgsock == -1 || accept() == -1) {
return(-1);
}
if (join) {
status = tt_session_join( sessid );
if (status != TT_OK) {
+ free(pats);
return (Tt_pattern *)tt_error_pointer( status );
}
}
_tt_syslog(0, LOG_ERR,
"_Tt_audit::entry(): ARG_INTEGER: func==%s",
_tt_enumname(func));
+ va_end(ap);
return TT_ERR_INTERNAL;
}
} break;
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);
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
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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)) {
_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",
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