From 62ee95bce23b0c17ab3167b93e10330405ca6481 Mon Sep 17 00:00:00 2001 From: Peter Howkins Date: Sat, 28 Apr 2018 21:44:27 +0100 Subject: [PATCH] dtimsstart: Coverity fixes --- cde/programs/dtimsstart/env.c | 3 ++- cde/programs/dtimsstart/file.c | 2 +- cde/programs/dtimsstart/main.c | 4 ++-- cde/programs/dtimsstart/remote.c | 17 +++++------------ cde/programs/dtimsstart/util.c | 2 +- cde/programs/dtimsstart/win.c | 4 +++- cde/programs/dtimsstart/ximserr.h | 2 +- 7 files changed, 15 insertions(+), 19 deletions(-) diff --git a/cde/programs/dtimsstart/env.c b/cde/programs/dtimsstart/env.c index 633e724f..90affbbc 100644 --- a/cde/programs/dtimsstart/env.c +++ b/cde/programs/dtimsstart/env.c @@ -270,10 +270,11 @@ int make_new_environ(oenv, sel) xmod_done = False; # ifdef old_hpux xinput = xhp_xinput_name(NULL); + xinput_done = (xinput) ? False : True; # else xinput = NULL; + xinput_done = True; # endif /* old_hpux */ - xinput_done = (xinput) ? False : True; proto = renv ? renv->proto : default_protocol(ims); setp = unsetp = 0; diff --git a/cde/programs/dtimsstart/file.c b/cde/programs/dtimsstart/file.c index be230a6a..2ad4f173 100644 --- a/cde/programs/dtimsstart/file.c +++ b/cde/programs/dtimsstart/file.c @@ -166,7 +166,7 @@ int read_cmd_conf() if (!(path = getenv("DTIMS_STARTCONF")) || !*path) { if ((p = getenv("DTIMS_CONFDIR")) && *p) conf_dir = p; - sprintf(path = buf, "%s/%s", conf_dir, DTIMS_CONFFILE); + snprintf(path = buf, sizeof(buf), "%s/%s", conf_dir, DTIMS_CONFFILE); } } DPR3(("read_cmd_conf(): path=%s\n", path)); diff --git a/cde/programs/dtimsstart/main.c b/cde/programs/dtimsstart/main.c index bc07067b..f0b7364d 100644 --- a/cde/programs/dtimsstart/main.c +++ b/cde/programs/dtimsstart/main.c @@ -662,7 +662,7 @@ static int set_locale_env(locale) env_name = "LANG"; env_value = getenv(env_name); if (env_value) - strcpy(buf, env_value); + snprintf(buf, sizeof(buf), "%s", env_value); if (locale && *locale) { if (!*buf || strcmp(locale, buf)) { bp = strcpyx(buf, env_name); *bp++ = '='; @@ -679,7 +679,7 @@ static int set_locale_env(locale) env_name = "LC_ALL"; env_value = getenv(env_name); if (env_value) - strcpy(buf2, env_value); + snprintf(buf2, sizeof(buf2), "%s", env_value); if (!*buf2 || strcmp(locale, buf2)) { bp = strcpyx(buf2, env_name); *bp++ = '='; strcpyx(bp, locale); diff --git a/cde/programs/dtimsstart/remote.c b/cde/programs/dtimsstart/remote.c index 0e665ed7..10985cfb 100644 --- a/cde/programs/dtimsstart/remote.c +++ b/cde/programs/dtimsstart/remote.c @@ -624,18 +624,11 @@ int exec_remote_ims(sel) if (ret != NoError) return ret; - if (ret == NoError) { - ac = 0; av = NULL; - ret = get_window_data(&ac, &av); - ret = NoError; - - if (ret != NoError) return ret; - } - - if (ret == NoError) { - put_xims_log("'%s' started for %s on %s.", - sel->name, userEnv.displayname, sel->hostname); - } + ac = 0; + av = NULL; + ret = get_window_data(&ac, &av); + put_xims_log("'%s' started for %s on %s.", + sel->name, userEnv.displayname, sel->hostname); DPR2(("exec_remote_ims(): ret=%s[%d]\n", error_name(ret), ret)); diff --git a/cde/programs/dtimsstart/util.c b/cde/programs/dtimsstart/util.c index c8c63727..945a2408 100644 --- a/cde/programs/dtimsstart/util.c +++ b/cde/programs/dtimsstart/util.c @@ -260,7 +260,7 @@ bool parse_dpy_str(display_str, host, dnum, snum, dnet) char buf[BUFSIZ], hostbuf[BUFSIZ], *p, *hp, *pdnum, *psnum; int isdnet = 0; - strcpy(buf, display_str); + snprintf(buf, sizeof(buf), "%s", display_str); /* extract host name */ if (!(p = strchr(buf, ':'))) return False; diff --git a/cde/programs/dtimsstart/win.c b/cde/programs/dtimsstart/win.c index 9869feca..8979f5b5 100644 --- a/cde/programs/dtimsstart/win.c +++ b/cde/programs/dtimsstart/win.c @@ -545,6 +545,7 @@ int start_selection_window() XtRealizeWidget(TopW); XtAppMainLoop(appC); /* not reached */ + return NoError; } static void finish_selection_window(end_window) @@ -1259,6 +1260,7 @@ int start_mode_window(cur_mode) XtAppMainLoop(appC); /* not rearched */ + return NoError; } static void finish_mode_window(end_window) @@ -1641,7 +1643,7 @@ int put_msg_win(type, msg) WaitingDialogReply = True; } - return reply == XmCR_OK ? True : False; + return reply = XmCR_OK ? True : False; } diff --git a/cde/programs/dtimsstart/ximserr.h b/cde/programs/dtimsstart/ximserr.h index 2cd017f7..a593839d 100644 --- a/cde/programs/dtimsstart/ximserr.h +++ b/cde/programs/dtimsstart/ximserr.h @@ -110,7 +110,7 @@ Extern char *errFuncName; #define setErrArg1(arg) _setErrArg(0, arg) #define setErrArg2(arg) _setErrArg(1, arg) #define setErrArg3(arg) _setErrArg(2, arg) -#define setErrFile(path) strcpy(errFilePath, (path)) +#define setErrFile(path) snprintf(errFilePath, sizeof(errFilePath), "%s", (path)) #define setErrFunc(name) errFuncName = (name) #undef Extern -- 2.25.1