From bb65b467900ea9eb1f7867c059fd26fac86c747c Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sun, 17 Nov 2013 09:55:18 +0400 Subject: [PATCH] Fix use of uninitialized memory in sigaction structure. Signed-off-by: Andrew Borodin --- lib/tty/tty-ncurses.c | 3 +-- lib/tty/tty.c | 8 ++++---- lib/utilunix.c | 2 +- lib/vfs/netutil.c | 3 ++- src/execute.c | 1 + src/main.c | 3 +-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/tty/tty-ncurses.c b/lib/tty/tty-ncurses.c index 5bf8612f1..ea4cbbd8f 100644 --- a/lib/tty/tty-ncurses.c +++ b/lib/tty/tty-ncurses.c @@ -93,12 +93,11 @@ tty_setup_sigwinch (void (*handler) (int)) #if (NCURSES_VERSION_MAJOR >= 4) && defined (SIGWINCH) struct sigaction act, oact; + memset (&act, 0, sizeof (act)); act.sa_handler = handler; sigemptyset (&act.sa_mask); #ifdef SA_RESTART act.sa_flags = SA_RESTART; -#else - act.sa_flags = 0; #endif /* SA_RESTART */ sigaction (SIGWINCH, &act, &oact); #endif /* SIGWINCH */ diff --git a/lib/tty/tty.c b/lib/tty/tty.c index d35ffabd6..13059fe77 100644 --- a/lib/tty/tty.c +++ b/lib/tty/tty.c @@ -33,6 +33,7 @@ #include #include #include +#include /* memset() */ #include /* exit() */ #ifdef HAVE_SYS_IOCTL_H @@ -118,12 +119,11 @@ tty_start_interrupt_key (void) { struct sigaction act; + memset (&act, 0, sizeof (act)); act.sa_handler = sigintr_handler; sigemptyset (&act.sa_mask); #ifdef SA_RESTART act.sa_flags = SA_RESTART; -#else - act.sa_flags = 0; #endif /* SA_RESTART */ sigaction (SIGINT, &act, NULL); } @@ -135,9 +135,9 @@ tty_enable_interrupt_key (void) { struct sigaction act; + memset (&act, 0, sizeof (act)); act.sa_handler = sigintr_handler; sigemptyset (&act.sa_mask); - act.sa_flags = 0; sigaction (SIGINT, &act, NULL); got_interrupt = 0; } @@ -149,9 +149,9 @@ tty_disable_interrupt_key (void) { struct sigaction act; + memset (&act, 0, sizeof (act)); act.sa_handler = SIG_IGN; sigemptyset (&act.sa_mask); - act.sa_flags = 0; sigaction (SIGINT, &act, NULL); } diff --git a/lib/utilunix.c b/lib/utilunix.c index 715561dce..de0f74211 100644 --- a/lib/utilunix.c +++ b/lib/utilunix.c @@ -180,9 +180,9 @@ my_system__save_sigaction_handlers (my_system_sigactions_t * sigactions) { struct sigaction ignore; + memset (&ignore, 0, sizeof (ignore)); ignore.sa_handler = SIG_IGN; sigemptyset (&ignore.sa_mask); - ignore.sa_flags = 0; sigaction (SIGINT, &ignore, &sigactions->intr); sigaction (SIGQUIT, &ignore, &sigactions->quit); diff --git a/lib/vfs/netutil.c b/lib/vfs/netutil.c index 6d6ed6660..3f756bd46 100644 --- a/lib/vfs/netutil.c +++ b/lib/vfs/netutil.c @@ -29,6 +29,7 @@ #include #include +#include /* memset() */ #include "lib/global.h" @@ -68,8 +69,8 @@ tcp_init (void) return; got_sigpipe = 0; + memset (&sa, 0, sizeof (sa)); sa.sa_handler = sig_pipe; - sa.sa_flags = 0; sigemptyset (&sa.sa_mask); sigaction (SIGPIPE, &sa, NULL); diff --git a/src/execute.c b/src/execute.c index 9dc8156be..66eaff019 100644 --- a/src/execute.c +++ b/src/execute.c @@ -154,6 +154,7 @@ do_suspend_cmd (void) { struct sigaction sigtstp_action; + memset (&sigtstp_action, 0, sizeof (sigtstp_action)); /* Make sure that the SIGTSTP below will suspend us directly, without calling ncurses' SIGTSTP handler; we *don't* want ncurses to redraw the screen immediately after the SIGCONT */ diff --git a/src/main.c b/src/main.c index b88e892a1..00e1a172d 100644 --- a/src/main.c +++ b/src/main.c @@ -203,6 +203,7 @@ init_sigchld (void) { struct sigaction sigchld_action; + memset (&sigchld_action, 0, sizeof (sigchld_action)); sigchld_action.sa_handler = #ifdef ENABLE_SUBSHELL mc_global.tty.use_subshell ? sigchld_handler : @@ -213,8 +214,6 @@ init_sigchld (void) #ifdef SA_RESTART sigchld_action.sa_flags = SA_RESTART; -#else - sigchld_action.sa_flags = 0; #endif /* !SA_RESTART */ if (sigaction (SIGCHLD, &sigchld_action, NULL) == -1) -- 2.11.4.GIT