From fbadfaa850e3d0fed43689b99853badb0c3d2b2c Mon Sep 17 00:00:00 2001 From: albert <> Date: Tue, 24 Feb 2004 04:14:36 +0000 Subject: [PATCH] protect against BSD pty w/ 20-bit minor --- free.1 | 2 ++ proc/devname.c | 1 + top.1 | 1 + 3 files changed, 4 insertions(+) diff --git a/free.1 b/free.1 index 203ca613..954c8d9c 100644 --- a/free.1 +++ b/free.1 @@ -36,6 +36,8 @@ The \fB\-V\fP displays version information. .SH "SEE ALSO" .BR ps (1), +.BR slabtop (1), +.BR vmstat (8), .BR top(1) .SH AUTHORS diff --git a/proc/devname.c b/proc/devname.c index 78c00cd3..d3684816 100644 --- a/proc/devname.c +++ b/proc/devname.c @@ -146,6 +146,7 @@ static int guess_name(char *restrict const buf, unsigned maj, unsigned min){ } tmpmin = min & 0x3f; /* FALL THROUGH */ case 3: /* /dev/[pt]ty[p-za-o][0-9a-z] is 936 */ + if(tmpmin > 255) return 0; // should never happen; array index protection t0 = "pqrstuvwxyzabcde"[tmpmin>>4]; t1 = "0123456789abcdef"[tmpmin&0x0f]; sprintf(buf, "/dev/tty%c%c", t0, t1); diff --git a/top.1 b/top.1 index 4520090e..e892289e 100644 --- a/top.1 +++ b/top.1 @@ -1214,6 +1214,7 @@ With invaluable help from: .BR free (1), .BR ps (1), .BR uptime (1), +.BR slabtop (1), .BR vmstat (8), .BR w (1).