Commit Graph

15 Commits

Author SHA1 Message Date
Stephen Heumann 8a3b1e25cd When forking the child process, wait until the child has exec'd before continuing in the parent.
Also includes a few other changes for safety, e.g. making the child exit via QuitGS rather than exit() or _exit().

The vfork_and_run() routine is based on code from my port of hush.
2016-01-09 12:46:38 -06:00
Stephen Heumann 494c69cf82 Eliminate large stack-allocated buffers, and set the stack size to 1.5k.
Also includes code to check the stack usage, which in my testing showed a maximum of 1025 bytes.
2016-01-08 23:45:11 -06:00
Stephen Heumann 972e6d98ba Fix a couple link errors in telnetd related to ORCA/C's handling of externs. 2015-06-01 16:42:47 -05:00
Stephen Heumann 581990e767 Misc. small changes for GNO and ORCA/C compatibility 2015-05-31 15:27:34 -05:00
ed 7aa7324a8f Convert telnetd(8) to use posix_openpt(2).
Some time ago I got some reports MPSAFE TTY broke telnetd(8). Even
though it turned out to be a different problem within the TTY code, I
spotted a small issue with telnetd(8). Instead of allocating PTY's using
openpty(3) or posix_openpt(2), it used its own PTY allocation routine.
This means that telnetd(8) still uses /dev/ptyXX-style devices.

I've also increased the size of line[]. Even though 16 should be enough,
we already use 13 bytes ("/dev/pts/999", including '\0'). 32 bytes gives
us a little more freedom.

Also enable -DSTREAMSPTY. Otherwise telnetd(8) strips the PTY's pathname
to the latest slash instead of just removing "/dev/" (e.g. /dev/pts/0 ->
0, instead of pts/0).

Reviewed by:	rink


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@184935 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2008-11-13 19:05:27 +00:00
markm a88d48b9df Damn. The previous mega-commit was incomplete WRT ANSIfication. This
fixes that.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@87155 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-11-30 22:28:07 +00:00
markm 820d180830 Very large style makeover.
1) ANSIfy.
2) Clean up ifdefs so that
   a) ones that never/always apply are appropriately either
      fully removed, or just the #if junk is removed.
   b) change #if defined(FOO) for appropiate values of FOO.
      (currently AUTHENTICATION and ENCRYPTION)
3) WARNS=2 fixing
4) GC other unused stuff

This code can now be unifdef(1)ed to make non-crypto telnet.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@87139 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-11-30 21:06:38 +00:00
markm 3efb267b2d Manually unifdef(1) CRAY, UNICOS, hpux and sun uselsess code.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@82497 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-08-29 14:16:17 +00:00
markm 0fd2377dcc Code merge and diff reduce with "base" telnet. This is the "later"
telnet, so it was treated as the reference code, except where later
commits were made to "base" telnet.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@81965 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-08-20 12:28:40 +00:00
kris 9de6e7ba10 output_data(), output_datalen() and netflush() didn't actually guarantee
to do what they are supposed to: under some circumstances output data would
be truncated, or the buffer would not actually be flushed (possibly leading
to overflows when the caller assumes the operation succeeded).  Change the
semantics so that these functions ensure they complete the operation before
returning.

Comment out diagnostic code enabled by '-D reports' which causes an
infinite recursion and an eventual crash.

Patch developed with assistance from ru and assar.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@80224 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-07-23 21:52:26 +00:00
ru 2c684cfa07 More potential buffer overflow fixes.
o Fixed `nfrontp' calculations in output_data().  If `remaining' is
  initially zero, it was possible for `nfrontp' to be decremented.

Noticed by:	dillon

o Replaced leaking writenet() with output_datalen():

:  * writenet
:  *
:  * Just a handy little function to write a bit of raw data to the net.
:  * It will force a transmit of the buffer if necessary
:  *
:  * arguments
:  *    ptr - A pointer to a character string to write
:  *    len - How many bytes to write
:  */
: 	void
: writenet(ptr, len)
: 	register unsigned char *ptr;
: 	register int len;
: {
: 	/* flush buffer if no room for new data) */
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: 	if ((&netobuf[BUFSIZ] - nfrontp) < len) {
: 		/* if this fails, don't worry, buffer is a little big */
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: 		netflush();
: 	}
:
: 	memmove(nfrontp, ptr, len);
: 	nfrontp += len;
:
: }  /* end of writenet */

What an irony!  :-)

o Optimized output_datalen() a bit.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@80038 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-07-20 12:02:30 +00:00
ru b3fb8c9630 Fixed the exploitable remote buffer overflow.
Reported on:	bugtraq
Obtained from:	Heimdal, NetBSD
Reviewed by:	obrien, imp


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@79981 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2001-07-19 17:48:57 +00:00
peter 1448d0f1e3 Add missing $FreeBSD$ to files that are NOT still on vendor a branch.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@63248 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
2000-07-16 05:48:49 +00:00
markm 6ba4d9bbdb Bring the FreeBSD changes to the virgin sources.
git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@29181 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
1997-09-07 07:02:53 +00:00
markm 0e15f670a1 This commit was generated by cvs2svn to compensate for changes in r29088,
which included commits to RCS files with non-trunk default branches.


git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@29089 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
1997-09-04 06:11:16 +00:00