Skip to content

Commit

Permalink
Fix use of uninitialized memory in sigaction structure.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Borodin <[email protected]>
  • Loading branch information
aborodin committed Nov 25, 2013
1 parent 255cc34 commit bb65b46
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
3 changes: 1 addition & 2 deletions lib/tty/tty-ncurses.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions lib/tty/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h> /* memset() */
#include <unistd.h> /* exit() */

#ifdef HAVE_SYS_IOCTL_H
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/utilunix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion lib/vfs/netutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include <stdlib.h>
#include <signal.h>
#include <string.h> /* memset() */

#include "lib/global.h"

Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 1 addition & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand All @@ -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)
Expand Down

0 comments on commit bb65b46

Please sign in to comment.