BusyBox Bug and Patch Tracking
BusyBox
  

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

- Relationships

- Notes
(0003754)
vapier
02-08-08 17:45

if ptsname() is returning NULL on your system, something is broken and you should fix that. ptsname_r() is not portable nor is it desirable to use in place of ptsname(). busybox is not a multithreaded application thus there is no need to use reentrant versions of any function.
 

- Issue History
Date Modified Username Field Change
02-08-08 13:42 jac_goudsmit New Issue
02-08-08 13:42 jac_goudsmit Status new => assigned
02-08-08 13:42 jac_goudsmit Assigned To  => BusyBox
02-08-08 17:45 vapier Note Added: 0003754
02-08-08 17:45 vapier Status assigned => closed
02-08-08 17:45 vapier Resolution open => won't fix


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker