From: Peter Howkins Date: Fri, 13 Apr 2018 18:08:50 +0000 (+0100) Subject: libtt: More coverity fixes X-Git-Tag: 2.2.4a~79 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fee6003be1f2cf474720606c54f45d4c5d3ea383;p=oweals%2Fcde.git libtt: More coverity fixes --- diff --git a/cde/lib/tt/bin/ttdbserverd/dm_server.C b/cde/lib/tt/bin/ttdbserverd/dm_server.C index 120d0c0a..84fb2323 100644 --- a/cde/lib/tt/bin/ttdbserverd/dm_server.C +++ b/cde/lib/tt/bin/ttdbserverd/dm_server.C @@ -1101,7 +1101,7 @@ _tt_isopen_1(_Tt_isopen_args *args, SVCXPRT * /* transp */) 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) { _tt_process_transaction(); } @@ -1533,7 +1533,7 @@ _tt_transaction_1(_Tt_transaction_args* args, SVCXPRT * /* transp */) return _tt_transaction_error(fd); } 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) { _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 memset(_tt_record, 0, sizeof(_tt_record)); 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()); isreclen = OID_KEY_LENGTH+MAX_PROP_LENGTH+sessionid.len(); res.result = iswrite(isfd, _tt_record); diff --git a/cde/lib/tt/bin/ttdbserverd/tt_isam_file.C b/cde/lib/tt/bin/ttdbserverd/tt_isam_file.C index deee12ac..980ca6b3 100644 --- a/cde/lib/tt/bin/ttdbserverd/tt_isam_file.C +++ b/cde/lib/tt/bin/ttdbserverd/tt_isam_file.C @@ -82,6 +82,9 @@ _Tt_isam_file currentRecordLength = -1; currentRecordNumber = -1; } + + maxRecordLength = 0; + minRecordLength = 0; } void _Tt_isam_file::setTtISAMFileDefaults () diff --git a/cde/lib/tt/bin/tttrace/tttrace_objs.C b/cde/lib/tt/bin/tttrace/tttrace_objs.C index f52cd1f9..526ab725 100644 --- a/cde/lib/tt/bin/tttrace/tttrace_objs.C +++ b/cde/lib/tt/bin/tttrace/tttrace_objs.C @@ -52,6 +52,7 @@ _Tt_trace_optobj::_Tt_trace_optobj() _has_outfile = 0; _has_session = 2; // 1 -> -S option, 2 -> set by default _has_command = 0; + _form = NO_FORM; } int diff --git a/cde/lib/tt/lib/api/c/api_handle.C b/cde/lib/tt/lib/api/c/api_handle.C index 22a9374c..ed49cd01 100644 --- a/cde/lib/tt/lib/api/c/api_handle.C +++ b/cde/lib/tt/lib/api/c/api_handle.C @@ -55,6 +55,7 @@ _Tt_api_handle_table:: _Tt_api_handle_table() { content = new _Tt_api_handle_list; + last_phandle = NULL; } /* @@ -615,6 +616,7 @@ print(FILE *f) const _Tt_api_callback:: _Tt_api_callback() { + callback = NULL; } _Tt_api_callback:: @@ -631,6 +633,8 @@ _Tt_api_handle_table:: _Tt_api_userdata:: _Tt_api_userdata() { + key = 0; + userdata = NULL; } _Tt_api_userdata:: diff --git a/cde/lib/tt/lib/db/tt_client_isam_record.h b/cde/lib/tt/lib/db/tt_client_isam_record.h index f56d8ab2..15f41118 100644 --- a/cde/lib/tt/lib/db/tt_client_isam_record.h +++ b/cde/lib/tt/lib/db/tt_client_isam_record.h @@ -43,7 +43,12 @@ class _Tt_client_isam_record : public _Tt_object { public: // 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 _Tt_client_isam_record (const _Tt_client_isam_key_descriptor_list_ptr &key_descriptor_list, diff --git a/cde/lib/tt/lib/db/tt_db_client.C b/cde/lib/tt/lib/db/tt_db_client.C index 22e210f1..808c5cfb 100644 --- a/cde/lib/tt/lib/db/tt_db_client.C +++ b/cde/lib/tt/lib/db/tt_db_client.C @@ -93,6 +93,14 @@ _Tt_db_client::_Tt_db_client (_Tt_db_results & status) setTtDBDefaults(); connectToDB(db_hostname); 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) diff --git a/cde/lib/tt/lib/db/tt_db_file.C b/cde/lib/tt/lib/db/tt_db_file.C index f3124f9f..4af667c7 100644 --- a/cde/lib/tt/lib/db/tt_db_file.C +++ b/cde/lib/tt/lib/db/tt_db_file.C @@ -45,6 +45,12 @@ _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) diff --git a/cde/lib/tt/lib/mp/mp_auth.C b/cde/lib/tt/lib/mp/mp_auth.C index b4babaf2..b44369d3 100644 --- a/cde/lib/tt/lib/mp/mp_auth.C +++ b/cde/lib/tt/lib/mp/mp_auth.C @@ -46,6 +46,10 @@ _Tt_auth(_Tt_auth_level auth_level) { _auth_level = auth_level; _auth_cookie = ""; + _rpc_program = 0; + _rpc_version = 0; + _entries_head = NULL; + _entries_tail = NULL; } diff --git a/cde/lib/tt/lib/mp/mp_desktop.C b/cde/lib/tt/lib/mp/mp_desktop.C index 36df33d2..ab2a6c3a 100644 --- a/cde/lib/tt/lib/mp/mp_desktop.C +++ b/cde/lib/tt/lib/mp/mp_desktop.C @@ -82,6 +82,7 @@ _Tt_desktop() { priv = (_Tt_desktop_private *)malloc(sizeof(_Tt_desktop_private)); priv->xd = (Display *)0; + user_io_handler = NULL; } diff --git a/cde/lib/tt/lib/mp/mp_procid.C b/cde/lib/tt/lib/mp/mp_procid.C index 72986fee..fca65dfb 100644 --- a/cde/lib/tt/lib/mp/mp_procid.C +++ b/cde/lib/tt/lib/mp/mp_procid.C @@ -58,6 +58,7 @@ _Tt_procid() _version = 0; _flags = 0; _mxdr_stream = (XDR *)0; + _program = 0; } diff --git a/cde/lib/tt/lib/util/tt_int_rec.C b/cde/lib/tt/lib/util/tt_int_rec.C index 5a83276a..56fc930c 100644 --- a/cde/lib/tt/lib/util/tt_int_rec.C +++ b/cde/lib/tt/lib/util/tt_int_rec.C @@ -40,6 +40,7 @@ _Tt_int_rec:: _Tt_int_rec() { + val = 0; } diff --git a/cde/lib/tt/lib/util/tt_object_table.C b/cde/lib/tt/lib/util/tt_object_table.C index 93d841ed..5ae54976 100644 --- a/cde/lib/tt/lib/util/tt_object_table.C +++ b/cde/lib/tt/lib/util/tt_object_table.C @@ -53,7 +53,8 @@ _Tt_object_table(int n) num_buckets = n; buckets = (_Tt_object_list_ptr *)calloc(n, sizeof(_Tt_object_list_ptr)); - _count = 0; + _count = 0; + _getkey = NULL; } _Tt_object_table:: diff --git a/cde/lib/tt/lib/util/tt_trace_parser.C b/cde/lib/tt/lib/util/tt_trace_parser.C index 6deeca1a..bf32b633 100644 --- a/cde/lib/tt/lib/util/tt_trace_parser.C +++ b/cde/lib/tt/lib/util/tt_trace_parser.C @@ -51,6 +51,8 @@ _Tt_trace_parser::_Tt_trace_parser() : trace_stream() { tracer_init(); + + mode = 0; // Technically this is openmode O_RDONLY but will be overwritten } _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'; tracer_init(); + + mode = 0; // Technically this is openmode O_RDONLY but will be overwritten } _Tt_trace_parser::_Tt_trace_parser(const char* script) { trace_stream = script; tracer_init(); + + mode = 0; // Technically this is openmode O_RDONLY but will be overwritten } void diff --git a/cde/lib/tt/lib/util/tt_trace_stream.C b/cde/lib/tt/lib/util/tt_trace_stream.C index fefc45ef..0b6f27f3 100644 --- a/cde/lib/tt/lib/util/tt_trace_stream.C +++ b/cde/lib/tt/lib/util/tt_trace_stream.C @@ -44,6 +44,7 @@ const int Tt_trace_buf_len = 4096; _Tt_trace_stream::_Tt_trace_stream() { + _is_entered = 0; } _Tt_trace_stream::_Tt_trace_stream( diff --git a/cde/lib/tt/lib/util/tt_xdr_utils.C b/cde/lib/tt/lib/util/tt_xdr_utils.C index 76d71665..8fdb5823 100644 --- a/cde/lib/tt/lib/util/tt_xdr_utils.C +++ b/cde/lib/tt/lib/util/tt_xdr_utils.C @@ -31,6 +31,7 @@ * * Copyright (c) 1990 by Sun Microsystems, Inc. */ +#include #if defined(ultrix) #include #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 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); #if defined(ultrix) || defined(__osf__) return (int *) xp->x_private; diff --git a/cde/lib/tt/mini_isam/isrename.c b/cde/lib/tt/mini_isam/isrename.c index 73cdeb30..3691f26e 100644 --- a/cde/lib/tt/mini_isam/isrename.c +++ b/cde/lib/tt/mini_isam/isrename.c @@ -80,9 +80,9 @@ isrename(oldname, newname) /* * Check that the odl and new filename are in the same directory. */ - (void)strcpy(olddir, oldname); + snprintf(olddir, sizeof(olddir), "%s", oldname); _removelast2(olddir); - (void)strcpy(newdir, newname); + snprintf(newdir, sizeof(newdir), "%s", newname); _removelast2(newdir); if (strcmp(newdir, olddir) != 0) { diff --git a/cde/lib/tt/slib/mp_observer.C b/cde/lib/tt/slib/mp_observer.C index 963784ac..1e58a7b8 100644 --- a/cde/lib/tt/slib/mp_observer.C +++ b/cde/lib/tt/slib/mp_observer.C @@ -59,6 +59,8 @@ _Tt_observer(_Tt_string ptid, int opnum, _reliability = reliability; _opnum = opnum; _scope = s; + + _state = TT_STATE_LAST; // BUG This class member is not set anywhere, but a getter function exists } diff --git a/cde/lib/tt/slib/mp_rpc_server.C b/cde/lib/tt/slib/mp_rpc_server.C index 0bd690f1..4df567d4 100644 --- a/cde/lib/tt/slib/mp_rpc_server.C +++ b/cde/lib/tt/slib/mp_rpc_server.C @@ -80,6 +80,8 @@ _Tt_rpc_server(int program, int version, int Rsocket, _Tt_auth &auth) _socket = Rsocket; _program = program; _auth = auth; + _rpc_fd = 0; + _transp = NULL; } diff --git a/cde/lib/tt/slib/mp_signature.C b/cde/lib/tt/slib/mp_signature.C index 62323573..6198d85a 100644 --- a/cde/lib/tt/slib/mp_signature.C +++ b/cde/lib/tt/slib/mp_signature.C @@ -79,6 +79,7 @@ _Tt_signature() _mangled_args = 0; ce_entry = 0; _timestamp = 0; + ce_entry = NULL; } _Tt_signature::