From e28620c71a2ccf71d97f4b11e0708548f46e5b0d Mon Sep 17 00:00:00 2001 From: Vitezslav Crhonek Date: Wed, 10 Oct 2018 09:15:21 +0200 Subject: [PATCH] Fix issues detected by static analysis --- expect-5.45.4-covscan-fixes.patch | 107 ++++++++++++++++++++++++++++++ expect.spec | 8 ++- 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 expect-5.45.4-covscan-fixes.patch diff --git a/expect-5.45.4-covscan-fixes.patch b/expect-5.45.4-covscan-fixes.patch new file mode 100644 index 0000000..f5f8d0b --- /dev/null +++ b/expect-5.45.4-covscan-fixes.patch @@ -0,0 +1,107 @@ +diff -up expect5.45.4/exp_chan.c.orig expect5.45.4/exp_chan.c +--- expect5.45.4/exp_chan.c.orig 2018-02-02 20:15:52.000000000 +0100 ++++ expect5.45.4/exp_chan.c 2018-10-09 14:14:44.851965292 +0200 +@@ -51,6 +51,8 @@ static void ExpWatchProc _ANSI_ARGS_((C + int mask)); + static int ExpGetHandleProc _ANSI_ARGS_((ClientData instanceData, + int direction, ClientData *handlePtr)); ++void exp_background_channelhandler _ANSI_ARGS_((ClientData, ++ int)); + + /* + * This structure describes the channel type structure for Expect-based IO: +diff -up expect5.45.4/exp_clib.c.orig expect5.45.4/exp_clib.c +--- expect5.45.4/exp_clib.c.orig 2018-10-09 14:14:44.841965281 +0200 ++++ expect5.45.4/exp_clib.c 2018-10-09 14:14:44.873965319 +0200 +@@ -37,6 +37,14 @@ would appreciate credit if this program + # endif + #endif + ++#ifdef HAVE_UNISTD_H ++# include ++#endif ++ ++//#ifdef HAVE_SYS_WAIT_H ++# include ++//#endif ++ + #ifdef HAVE_SYS_FCNTL_H + # include + #else +@@ -2196,6 +2204,7 @@ int exp_getptyslave(); + #define sysreturn(x) return(errno = x, -1) + + void exp_init_pty(); ++void exp_init_tty(); + + /* + The following functions are linked from the Tcl library. They +@@ -2715,6 +2724,7 @@ exp_spawnl TCL_VARARGS_DEF(char *,arg1) + argv[i] = va_arg(args,char *); + if (!argv[i]) break; + } ++ va_end(args); + i = exp_spawnv(argv[0],argv+1); + free((char *)argv); + return(i); +@@ -3188,6 +3198,7 @@ exp_expectl TCL_VARARGS_DEF(int,arg1) + /* Ultrix 4.2 compiler refuses enumerations comparison!? */ + if ((int)type < 0 || (int)type >= (int)exp_bogus) { + fprintf(stderr,"bad type (set %d) in exp_expectl\n",i); ++ va_end(args); + sysreturn(EINVAL); + } + +@@ -3253,6 +3264,7 @@ exp_fexpectl TCL_VARARGS_DEF(FILE *,arg1 + /* Ultrix 4.2 compiler refuses enumerations comparison!? */ + if ((int)type < 0 || (int)type >= (int)exp_bogus) { + fprintf(stderr,"bad type (set %d) in exp_expectl\n",i); ++ va_end(args); + sysreturn(EINVAL); + } + +diff -up expect5.45.4/exp_log.c.orig expect5.45.4/exp_log.c +--- expect5.45.4/exp_log.c.orig 2018-10-09 14:14:44.838965277 +0200 ++++ expect5.45.4/exp_log.c 2018-10-09 14:14:44.852965294 +0200 +@@ -174,7 +174,10 @@ expStdoutLog TCL_VARARGS_DEF(int,arg1) + force_stdout = TCL_VARARGS_START(int,arg1,args); + fmt = va_arg(args,char *); + +- if ((!tsdPtr->logUser) && (!force_stdout) && (!tsdPtr->logAll)) return; ++ if ((!tsdPtr->logUser) && (!force_stdout) && (!tsdPtr->logAll)) { ++ va_end(args); ++ return; ++ } + + (void) vsnprintf(bigbuf,sizeof(bigbuf),fmt,args); + expDiagWriteBytes(bigbuf,-1); +diff -up expect5.45.4/exp_main_sub.c.orig expect5.45.4/exp_main_sub.c +--- expect5.45.4/exp_main_sub.c.orig 2018-10-09 14:14:44.848965289 +0200 ++++ expect5.45.4/exp_main_sub.c 2018-10-09 14:14:44.852965294 +0200 +@@ -57,6 +57,7 @@ int exp_cmdlinecmds = FALSE; + int exp_interactive = FALSE; + int exp_buffer_command_input = FALSE;/* read in entire cmdfile at once */ + int exp_fgets(); ++int exp_tty_cooked_echo(Tcl_Interp *interp, exp_tty *tty_old, int *was_raw, int *was_echo); + + Tcl_Interp *exp_interp; /* for use by signal handlers who can't figure out */ + /* the interpreter directly */ +diff -up expect5.45.4/pty_termios.c.orig expect5.45.4/pty_termios.c +--- expect5.45.4/pty_termios.c.orig 2018-10-09 14:17:00.132127498 +0200 ++++ expect5.45.4/pty_termios.c 2018-10-09 14:33:59.393315570 +0200 +@@ -105,6 +105,7 @@ with openpty which supports 4000 while p + + void expDiagLog(); + void expDiagLogPtr(); ++char *expErrnoMsg(int errorNo); + + #include + /*extern char *sys_errlist[];*/ +@@ -189,6 +190,7 @@ static char slave_name[MAXPTYNAMELEN]; + #endif /* HAVE_SCO_CLIST_PTYS */ + + #ifdef HAVE_OPENPTY ++#include + static char master_name[64]; + static char slave_name[64]; + #endif diff --git a/expect.spec b/expect.spec index c672378..b8aaebc 100644 --- a/expect.spec +++ b/expect.spec @@ -5,7 +5,7 @@ Summary: A program-script interaction and testing utility Name: expect Version: %{majorver} -Release: 6%{?dist} +Release: 7%{?dist} License: Public Domain URL: https://core.tcl.tk/expect/index Source: http://downloads.sourceforge.net/%{name}/%{name}%{version}.tar.gz @@ -29,6 +29,8 @@ Patch6: expect-5.45-segfault-with-stubs.patch Patch7: expect-5.45-fd-leak.patch # Patch8: unificates usage message of expect binary and man page, adds -h flag Patch8: expect-5.45.4-unification-of-usage-and-man-page.patch +# Patch9: fixes issues detected by static analysis +Patch9: expect-5.45.4-covscan-fixes.patch # examples patches # Patch100: changes random function Patch100: expect-5.32.2-random.patch @@ -91,6 +93,7 @@ of expectk. %patch6 -p1 -b .segfault-with-stubs %patch7 -p1 -b .fd-leak %patch8 -p1 -b .unification-of-usage-and-man-page +%patch9 -p1 -b .covscan-fixes # examples fixes %patch100 -p1 -b .random %patch101 -p1 -b .mkpasswd-dash @@ -174,6 +177,9 @@ chrpath --delete $RPM_BUILD_ROOT%{_libdir}/libexpect%{version}.so %{_mandir}/man1/tknewsbiff.1* %changelog +* Wed Oct 10 2018 Vitezslav Crhonek - 5.45.4-7 +- Fix issues detected by static analysis + * Wed Aug 29 2018 Vitezslav Crhonek - 5.45.4-6 - Unificate and improve both man page and usage message of expect