1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

libtt: More coverity fixes

This commit is contained in:
Peter Howkins 2018-04-13 19:08:50 +01:00
parent 17101b6f4c
commit fee6003be1
19 changed files with 56 additions and 8 deletions

View file

@ -1101,7 +1101,7 @@ _tt_isopen_1(_Tt_isopen_args *args, SVCXPRT * /* transp */)
memcpy(_tt_log_file, (char *)db_path, prefix_len); memcpy(_tt_log_file, (char *)db_path, prefix_len);
strcpy(_tt_log_file+prefix_len, _TT_LOG_FILE); snprintf(_tt_log_file + prefix_len, MAXPATHLEN - prefix_len, "%s", _TT_LOG_FILE);
if (access(_tt_log_file, F_OK) == 0) { if (access(_tt_log_file, F_OK) == 0) {
_tt_process_transaction(); _tt_process_transaction();
} }
@ -1533,7 +1533,7 @@ _tt_transaction_1(_Tt_transaction_args* args, SVCXPRT * /* transp */)
return _tt_transaction_error(fd); return _tt_transaction_error(fd);
} }
memcpy(_tt_log_file, db_path, prefix_len); memcpy(_tt_log_file, db_path, prefix_len);
strcpy(_tt_log_file+prefix_len, _TT_LOG_FILE); snprintf(_tt_log_file + prefix_len, MAXPATHLEN - prefix_len, "%s", _TT_LOG_FILE);
if (access(_tt_log_file, F_OK) == 0) { if (access(_tt_log_file, F_OK) == 0) {
_tt_process_transaction(); _tt_process_transaction();
} }
@ -1791,7 +1791,7 @@ _tt_addsession_1(_Tt_session_args *argp, SVCXPRT * /* transp */)
// zero out _tt_record, which is where tp points // zero out _tt_record, which is where tp points
memset(_tt_record, 0, sizeof(_tt_record)); memset(_tt_record, 0, sizeof(_tt_record));
memcpy(tp->objkey, argp->oidkey.oidkey_val, argp->oidkey.oidkey_len); memcpy(tp->objkey, argp->oidkey.oidkey_val, argp->oidkey.oidkey_len);
strcpy(tp->propname, filejoin_prop); snprintf(tp->propname, sizeof(tp->propname), "%s", (char *) filejoin_prop);
memcpy(tp->propval, (char *) sessionid, sessionid.len()); memcpy(tp->propval, (char *) sessionid, sessionid.len());
isreclen = OID_KEY_LENGTH+MAX_PROP_LENGTH+sessionid.len(); isreclen = OID_KEY_LENGTH+MAX_PROP_LENGTH+sessionid.len();
res.result = iswrite(isfd, _tt_record); res.result = iswrite(isfd, _tt_record);

View file

@ -82,6 +82,9 @@ _Tt_isam_file
currentRecordLength = -1; currentRecordLength = -1;
currentRecordNumber = -1; currentRecordNumber = -1;
} }
maxRecordLength = 0;
minRecordLength = 0;
} }
void _Tt_isam_file::setTtISAMFileDefaults () void _Tt_isam_file::setTtISAMFileDefaults ()

View file

@ -52,6 +52,7 @@ _Tt_trace_optobj::_Tt_trace_optobj()
_has_outfile = 0; _has_outfile = 0;
_has_session = 2; // 1 -> -S option, 2 -> set by default _has_session = 2; // 1 -> -S option, 2 -> set by default
_has_command = 0; _has_command = 0;
_form = NO_FORM;
} }
int int

View file

@ -55,6 +55,7 @@ _Tt_api_handle_table::
_Tt_api_handle_table() _Tt_api_handle_table()
{ {
content = new _Tt_api_handle_list; content = new _Tt_api_handle_list;
last_phandle = NULL;
} }
/* /*
@ -615,6 +616,7 @@ print(FILE *f) const
_Tt_api_callback:: _Tt_api_callback::
_Tt_api_callback() _Tt_api_callback()
{ {
callback = NULL;
} }
_Tt_api_callback:: _Tt_api_callback::
@ -631,6 +633,8 @@ _Tt_api_handle_table::
_Tt_api_userdata:: _Tt_api_userdata::
_Tt_api_userdata() _Tt_api_userdata()
{ {
key = 0;
userdata = NULL;
} }
_Tt_api_userdata:: _Tt_api_userdata::

View file

@ -43,7 +43,12 @@
class _Tt_client_isam_record : public _Tt_object { class _Tt_client_isam_record : public _Tt_object {
public: public:
// Dummy constructor needed to make tt_client_isam_record_utils.cc happy // Dummy constructor needed to make tt_client_isam_record_utils.cc happy
_Tt_client_isam_record () {} _Tt_client_isam_record ()
{
currentLength = 0;
maxLength = 0;
minLength = 0;
}
// Real constructor // Real constructor
_Tt_client_isam_record (const _Tt_client_isam_key_descriptor_list_ptr &key_descriptor_list, _Tt_client_isam_record (const _Tt_client_isam_key_descriptor_list_ptr &key_descriptor_list,

View file

@ -93,6 +93,14 @@ _Tt_db_client::_Tt_db_client (_Tt_db_results & status)
setTtDBDefaults(); setTtDBDefaults();
connectToDB(db_hostname); connectToDB(db_hostname);
status = dbConnectionResults; status = dbConnectionResults;
iserrno = 0;
isrecnum = 0;
isreclen = 0;
#if !defined(OPT_TLI)
dbSocket.sin_family = 0;
dbSocket.sin_port = 0;
#endif
} }
_Tt_db_client::_Tt_db_client (const _Tt_string &hostname, _Tt_db_results & status) _Tt_db_client::_Tt_db_client (const _Tt_string &hostname, _Tt_db_results & status)

View file

@ -45,6 +45,12 @@
_Tt_db_file:: _Tt_db_file::
_Tt_db_file() _Tt_db_file()
{ {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
checkedDatabase = FALSE;
directoryFlag = FALSE;
dbFileObjectsCacheLevel = -1;
dbFilePropertiesCacheLevel = -1;
dbResults = TT_DB_OK;
} }
_Tt_db_file::_Tt_db_file (const _Tt_string &file) _Tt_db_file::_Tt_db_file (const _Tt_string &file)

View file

@ -46,6 +46,10 @@ _Tt_auth(_Tt_auth_level auth_level)
{ {
_auth_level = auth_level; _auth_level = auth_level;
_auth_cookie = ""; _auth_cookie = "";
_rpc_program = 0;
_rpc_version = 0;
_entries_head = NULL;
_entries_tail = NULL;
} }

View file

@ -82,6 +82,7 @@ _Tt_desktop()
{ {
priv = (_Tt_desktop_private *)malloc(sizeof(_Tt_desktop_private)); priv = (_Tt_desktop_private *)malloc(sizeof(_Tt_desktop_private));
priv->xd = (Display *)0; priv->xd = (Display *)0;
user_io_handler = NULL;
} }

View file

@ -58,6 +58,7 @@ _Tt_procid()
_version = 0; _version = 0;
_flags = 0; _flags = 0;
_mxdr_stream = (XDR *)0; _mxdr_stream = (XDR *)0;
_program = 0;
} }

View file

@ -40,6 +40,7 @@
_Tt_int_rec:: _Tt_int_rec::
_Tt_int_rec() _Tt_int_rec()
{ {
val = 0;
} }

View file

@ -53,7 +53,8 @@ _Tt_object_table(int n)
num_buckets = n; num_buckets = n;
buckets = (_Tt_object_list_ptr *)calloc(n, buckets = (_Tt_object_list_ptr *)calloc(n,
sizeof(_Tt_object_list_ptr)); sizeof(_Tt_object_list_ptr));
_count = 0; _count = 0;
_getkey = NULL;
} }
_Tt_object_table:: _Tt_object_table::

View file

@ -51,6 +51,8 @@ _Tt_trace_parser::_Tt_trace_parser()
: trace_stream() : trace_stream()
{ {
tracer_init(); tracer_init();
mode = 0; // Technically this is openmode O_RDONLY but will be overwritten
} }
_Tt_trace_parser::_Tt_trace_parser(_Tt_trace_parser& templ) _Tt_trace_parser::_Tt_trace_parser(_Tt_trace_parser& templ)
@ -94,12 +96,16 @@ _Tt_trace_parser::_Tt_trace_parser(int fd)
trace_stream[trace_stream.len()] = '\0'; trace_stream[trace_stream.len()] = '\0';
tracer_init(); tracer_init();
mode = 0; // Technically this is openmode O_RDONLY but will be overwritten
} }
_Tt_trace_parser::_Tt_trace_parser(const char* script) _Tt_trace_parser::_Tt_trace_parser(const char* script)
{ {
trace_stream = script; trace_stream = script;
tracer_init(); tracer_init();
mode = 0; // Technically this is openmode O_RDONLY but will be overwritten
} }
void void

View file

@ -44,6 +44,7 @@ const int Tt_trace_buf_len = 4096;
_Tt_trace_stream::_Tt_trace_stream() _Tt_trace_stream::_Tt_trace_stream()
{ {
_is_entered = 0;
} }
_Tt_trace_stream::_Tt_trace_stream( _Tt_trace_stream::_Tt_trace_stream(

View file

@ -31,6 +31,7 @@
* *
* Copyright (c) 1990 by Sun Microsystems, Inc. * Copyright (c) 1990 by Sun Microsystems, Inc.
*/ */
#include <stdint.h>
#if defined(ultrix) #if defined(ultrix)
#include <rpc/types.h> #include <rpc/types.h>
#define bool_t int #define bool_t int
@ -101,7 +102,7 @@ tt_x_inline(XDR *xp, int len)
/* It is better to promote len to caddr_t than demote x_base to /* It is better to promote len to caddr_t than demote x_base to
int for 64 bit arch. int for 64 bit arch.
*/ */
if (len > 0 && (caddr_t) len < xp->x_base) { if (len > 0 && (caddr_t) (intptr_t) len < xp->x_base) {
xp->x_handy += RNDUP (len); xp->x_handy += RNDUP (len);
#if defined(ultrix) || defined(__osf__) #if defined(ultrix) || defined(__osf__)
return (int *) xp->x_private; return (int *) xp->x_private;

View file

@ -80,9 +80,9 @@ isrename(oldname, newname)
/* /*
* Check that the odl and new filename are in the same directory. * Check that the odl and new filename are in the same directory.
*/ */
(void)strcpy(olddir, oldname); snprintf(olddir, sizeof(olddir), "%s", oldname);
_removelast2(olddir); _removelast2(olddir);
(void)strcpy(newdir, newname); snprintf(newdir, sizeof(newdir), "%s", newname);
_removelast2(newdir); _removelast2(newdir);
if (strcmp(newdir, olddir) != 0) { if (strcmp(newdir, olddir) != 0) {

View file

@ -59,6 +59,8 @@ _Tt_observer(_Tt_string ptid, int opnum,
_reliability = reliability; _reliability = reliability;
_opnum = opnum; _opnum = opnum;
_scope = s; _scope = s;
_state = TT_STATE_LAST; // BUG This class member is not set anywhere, but a getter function exists
} }

View file

@ -80,6 +80,8 @@ _Tt_rpc_server(int program, int version, int Rsocket, _Tt_auth &auth)
_socket = Rsocket; _socket = Rsocket;
_program = program; _program = program;
_auth = auth; _auth = auth;
_rpc_fd = 0;
_transp = NULL;
} }

View file

@ -79,6 +79,7 @@ _Tt_signature()
_mangled_args = 0; _mangled_args = 0;
ce_entry = 0; ce_entry = 0;
_timestamp = 0; _timestamp = 0;
ce_entry = NULL;
} }
_Tt_signature:: _Tt_signature::