| Anonymous | Login | Signup for a new account | 11-10-2008 11:35 PST |
| Main | My View | View Issues | Change Log | Docs |
| Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||||
| ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||||
| 0002094 | [BusyBox] Networking Support | minor | sometimes | 02-08-08 13:42 | 02-08-08 17:45 | ||||
| Reporter | jac_goudsmit | View Status | public | ||||||
| Assigned To | BusyBox | ||||||||
| Priority | normal | Resolution | won't fix | ||||||
| Status | closed | Product Version | svn | ||||||
| Summary | 0002094: Use ptsname_r instead of ptsname in telnetd.c | ||||||||
| Description |
The Busybox telnet daemon (networking/telnetd.c) uses ptsname(3) to find the slave device of a terminal. However apparently at least in some environments this function fails consistently: it always returns NULL. The ptsname_r(3) function is a replacement for ptsname() that doesn't require thread-local storage and is likely to work in more environments, so I propose that the code be changed to use ptsname_r instead of ptsname/strcpy or equivalent. |
||||||||
| Additional Information |
I found this problem in the Busybox (1.00rc2) that runs on the Linksys NAS200 Router and published instructions on how to fix it at http://www.nslu2-linux.org/wiki/NAS200/Telnet. [^] Here is a diff -u for a patch in that version: [start of diff] --- ../../nas_pristine/NAS200_V34R62_GPL/source/busybox-1.00-rc2/networking/telnetd.c 2006-07-31 19:04:04.000000000 -0700 +++ source/busybox-1.00-rc2/networking/telnetd.c 2008-01-19 23:44:19.000000000 -0700 @@ -197,7 +197,7 @@ if (p > 0) { grantpt(p); unlockpt(p); - strcpy(line, ptsname(p)); + ptsname_r(p, line, 32); return(p); } #else [end of diff] The Busybox code has changed slightly since then. Based on the latest SVN version and the fact that apparently ptsname_r is Linux specific, I would propose something similar to the following: [start of diff] --- telnetd.c.org 2008-02-08 16:23:09.000000000 -0500 +++ telnetd.c 2008-02-08 16:32:02.000000000 -0500 @@ -165,10 +165,15 @@ unlockpt(p); name = ptsname(p); if (!name) { - bb_perror_msg("ptsname error (is /dev/pts mounted?)"); - return -1; + if (ptsname_r(p, line, size)) { + bb_perror_msg("ptsname error (is /dev/pts mounted?)"); + return -1; + } + } + else + { + safe_strncpy(line, name, size); } - safe_strncpy(line, name, size); return p; } #else [end of diff] I leave it to the Powers That Be to decide whether this means we need a new config option DEVPTS_BROKEN_PTSNAME or somesuch :-) |
||||||||
| Attached Files | |||||||||
|
|
|||||||||
| Copyright © 2000 - 2006 Mantis Group |