From 0231385023e4877b1163fec52025e6768411f06b Mon Sep 17 00:00:00 2001 From: albert <> Date: Sun, 9 Jul 2006 06:58:39 +0000 Subject: [PATCH] fix the low_density_names table, maybe --- proc/devname.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/proc/devname.c b/proc/devname.c index d9735569..158bf496 100644 --- a/proc/devname.c +++ b/proc/devname.c @@ -46,10 +46,11 @@ typedef struct tty_map_node { struct tty_map_node *next; - unsigned major_number; - unsigned minor_first, minor_last; + unsigned short devfs_type; // bool + unsigned short major_number; + unsigned minor_first; + unsigned minor_last; char name[16]; - char devfs_type; } tty_map_node; static tty_map_node *tty_map = NULL; @@ -66,7 +67,7 @@ static void load_drivers(void){ if(bytes == -1) goto fail; buf[bytes] = '\0'; p = buf; - while(( p = strstr(p, " /dev/") )){ + while(( p = strstr(p, " /dev/") )){ // " /dev/" is the second column tty_map_node *tmn; int len; char *end; @@ -83,7 +84,9 @@ static void load_drivers(void){ len -= 2; tmn->devfs_type = 1; } - strncpy(tmn->name, p, len); + if(len >= sizeof tmn->name) + len = sizeof tmn->name - 1; // mangle it to avoid overflow + memcpy(tmn->name, p, len); p = end; /* set p to point past the %d as well if there is one */ while(*p == ' ') p++; tmn->major_number = atoi(p); @@ -143,7 +146,7 @@ static const char low_density_names[][6] = { "SG0", "SMX0", "SMX1", "SMX2", "MM0", "MM1", -"CPM0", "CPM1", "CPM2", "CPM3", "CPM4", "CPM5", +"CPM0", "CPM1", "CPM2", "CPM3", /* "CPM4", "CPM5", */ // bad allocation? "IOC0", "IOC1", "IOC2", "IOC3", "IOC4", "IOC5", "IOC6", "IOC7", "IOC8", "IOC9", "IOC10", "IOC11", "IOC12", "IOC13", "IOC14", "IOC15", "IOC16", "IOC17", "IOC18", "IOC19", "IOC20", "IOC21", "IOC22", "IOC23", @@ -162,9 +165,23 @@ static const char low_density_names[][6] = { "AT8", "AT9", "AT10", "AT11", "AT12", "AT13", "AT14", "AT15", "NX0", "NX1", "NX2", "NX3", "NX4", "NX5", "NX6", "NX7", "NX8", "NX9", "NX10", "NX11", "NX12", "NX13", "NX14", "NX15", -"J0", +"J0", // minor is 186 }; +#if 0 +// test code +#include +#define AS(x) (sizeof(x)/sizeof((x)[0])) +int main(int argc, char *argv[]){ + int i = 0; + while(i