protect against BSD pty w/ 20-bit minor

This commit is contained in:
albert 2004-02-24 04:14:36 +00:00
parent 8620fc26cf
commit fbadfaa850
3 changed files with 4 additions and 0 deletions

2
free.1
View File

@ -36,6 +36,8 @@ The \fB\-V\fP displays version information.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR ps (1), .BR ps (1),
.BR slabtop (1),
.BR vmstat (8),
.BR top(1) .BR top(1)
.SH AUTHORS .SH AUTHORS

View File

@ -146,6 +146,7 @@ static int guess_name(char *restrict const buf, unsigned maj, unsigned min){
} }
tmpmin = min & 0x3f; /* FALL THROUGH */ tmpmin = min & 0x3f; /* FALL THROUGH */
case 3: /* /dev/[pt]ty[p-za-o][0-9a-z] is 936 */ 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]; t0 = "pqrstuvwxyzabcde"[tmpmin>>4];
t1 = "0123456789abcdef"[tmpmin&0x0f]; t1 = "0123456789abcdef"[tmpmin&0x0f];
sprintf(buf, "/dev/tty%c%c", t0, t1); sprintf(buf, "/dev/tty%c%c", t0, t1);

1
top.1
View File

@ -1214,6 +1214,7 @@ With invaluable help from:
.BR free (1), .BR free (1),
.BR ps (1), .BR ps (1),
.BR uptime (1), .BR uptime (1),
.BR slabtop (1),
.BR vmstat (8), .BR vmstat (8),
.BR w (1). .BR w (1).