[1.16.2] Can't stop "ping" with CTRL+c
Kevin Cernekee
cernekee at gmail.com
Wed Jul 13 15:10:28 UTC 2011
On Wed, Jul 13, 2011 at 12:31 AM, Denys Vlasenko
<vda.linux at googlemail.com> wrote:
> + ssize_t s = open_read_close("/sys/class/tty/console/active",
> + &console[5], sizeof(console) - 5);
> + if (s > 0) {
> + /* found active console via sysfs (Linux 2.6.38+ only) */
> + console[4 + s] = 0;
>
> Why 4, not 5? And if changed to 5, it can overflow console[],
> need to use sizeof(console) - 6 in read.
The last character read from sysfs is a newline, which needs to be
removed in order to have a valid pathname.
So, if open_read_close returns 2, then console[5] is our device name
and console[6] is the unwanted newline.
> Now we will require that linux/vt.h exists. This may be not such a good idea:
> some people do use semibroken toolchain where some headers are missing.
I figured it was OK because init/init.c also has this dependency...
More information about the busybox
mailing list