1 From 3b67473e16aaf2f83cb8ac18c13c9183a8e3c7b2 Mon Sep 17 00:00:00 2001
2 From: Hans Ulrich Niedermann <hun@n-dimensional.de>
3 Date: Tue, 3 Apr 2018 18:37:33 +0200
4 Subject: [PATCH] Apply CVE-2018-0492.patch from Debian package
7 beep.c | 53 ++++++++++++++++++++++++-----------------------------
8 1 file changed, 24 insertions(+), 29 deletions(-)
10 diff --git a/beep.c b/beep.c
11 index d46adc8..f6781e8 100644
14 @@ -109,6 +109,7 @@ void do_beep(int freq) {
18 + memset(&e, 0, sizeof(e));
22 @@ -124,10 +125,6 @@ void do_beep(int freq) {
23 /* If we get interrupted, it would be nice to not leave the speaker beeping in
25 void handle_signal(int signum) {
28 - free(console_device);
33 @@ -258,7 +255,7 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) {
36 case 'e' : /* also --device */
37 - console_device = strdup(optarg);
38 + console_device = optarg;
40 case 'h' : /* notice that this is also --help */
42 @@ -277,26 +274,6 @@ void play_beep(beep_parms_t parms) {
43 "%d delay after) @ %.2f Hz\n",
44 parms.reps, parms.length, parms.delay, parms.end_delay, parms.freq);
46 - /* try to snag the console */
48 - console_fd = open(console_device, O_WRONLY);
50 - if((console_fd = open("/dev/tty0", O_WRONLY)) == -1)
51 - console_fd = open("/dev/vc/0", O_WRONLY);
53 - if(console_fd == -1) {
54 - fprintf(stderr, "Could not open %s for writing\n",
55 - console_device != NULL ? console_device : "/dev/tty0 or /dev/vc/0");
56 - printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */
61 - if (ioctl(console_fd, EVIOCGSND(0)) != -1)
62 - console_type = BEEP_TYPE_EVDEV;
64 - console_type = BEEP_TYPE_CONSOLE;
67 for (i = 0; i < parms.reps; i++) { /* start beep */
69 @@ -306,8 +283,6 @@ void play_beep(beep_parms_t parms) {
70 if(parms.end_delay || (i+1 < parms.reps))
71 usleep(1000*parms.delay); /* wait... */
78 @@ -329,6 +304,26 @@ int main(int argc, char **argv) {
79 signal(SIGTERM, handle_signal);
80 parse_command_line(argc, argv, parms);
82 + /* try to snag the console */
84 + console_fd = open(console_device, O_WRONLY);
86 + if((console_fd = open("/dev/tty0", O_WRONLY)) == -1)
87 + console_fd = open("/dev/vc/0", O_WRONLY);
89 + if(console_fd == -1) {
90 + fprintf(stderr, "Could not open %s for writing\n",
91 + console_device != NULL ? console_device : "/dev/tty0 or /dev/vc/0");
92 + printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */
97 + if (ioctl(console_fd, EVIOCGSND(0)) != -1)
98 + console_type = BEEP_TYPE_EVDEV;
100 + console_type = BEEP_TYPE_CONSOLE;
102 /* this outermost while loop handles the possibility that -n/--new has been
103 used, i.e. that we have multiple beeps specified. Each iteration will
104 play, then free() one parms instance. */
105 @@ -366,8 +361,8 @@ int main(int argc, char **argv) {
110 - free(console_device);