On Wed, Jul 13, 2011 at 12:31 AM, Denys Vlasenko <[email protected]> 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... _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
