🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Steven M. Schultz Wed, 26 Aug 1992 04:24
telnet netdata dump misformatted, workaround for _doprnt (#70)
#50
Author: Steven M. Schultz
Date: Wed, 26 Aug 1992 04:24
81 lines
2911 bytes
Subject: telnet netdata dump misformatted, workaround for _doprnt (#70)
Index:	ucb/telnet.c 2.11BSD

Description:
	Using "toggle netdata" results in a misformatted hex display.

Repeat-By:
	Issue a "toggle netdata" command and observe the hex dump produced
	by telnet.  There are extra 0 characters present because of the
	way _doprnt processes format specs such as "%.2x".

	The 4.3BSD _doprnt generates the expected two digit display for
	each byte.  The 2.11BSD _doprnt does not, instead a leading 0
	is produced!

	The following test program will show how the 2.11BSD _doprnt
	handles the various attempts at producing a 2 hex digit output
	for a byte of data:

	-------------------------cut here----------------------------
	char	*p;

main()
	{
	printf("2.2|%2.2x\n", 0xff);
	printf(".2|%.2x\n", 0xff);
	printf("2|%2x\n", 0xff);
	printf("02|%02x\n", 0xff);
	putchar('\n');
	printf("2.2|%2.2x\n", 0x05);
	printf(".2|%.2x\n", 0x05);
	printf("2|%2x\n", 0x05);
	printf("02|%02x\n", 0x05);
	}
	-------------------------cut here------------------------
	Results:
 2.2|0ff
 .2|0ff
 2|ff
 02|ff
 
 2.2|05
 .2|05
 2| 5
 02|05

Fix:
	Rewriting _doprnt is not something i really want to do at the
	moment (volunteers?).  The 4.3BSD assembly language version makes 
	use of Vax instructions such as "editpc", etc - not pleasant things to
	emulate.  The 4.3Reno version is written in C but appears to
	be insistent/dependent on having an "unsigned long" data type which
	is not currently available in the 2.11BSD C compiler.

	Rather than rewriting/fixing doprnt.s the format spec was changed
	in telnet.c to produce the desired output.

	Apply the (very small) change to telnet.c and reinstall 'telnet'.
	You'll first want to install patch #69 which fixes the %c bug
	in _doprnt.

-----------------------cut here-------------------------------
*** /usr/src/ucb/telnet.c.old	Tue Jul 31 13:39:39 1990
--- /usr/src/ucb/telnet.c	Tue Aug 25 13:33:00 1992
***************
*** 551,557 ****
  	pThis = buffer;
  	buffer = buffer+min(length, BYTES_PER_LINE);
  	while (pThis < buffer) {
! 	    fprintf(NetTrace, "%.2x", (*pThis)&0xff);
  	    pThis++;
  	}
  	fprintf(NetTrace, "\n");
--- 551,557 ----
  	pThis = buffer;
  	buffer = buffer+min(length, BYTES_PER_LINE);
  	while (pThis < buffer) {
! 	    fprintf(NetTrace, "%02x", (*pThis)&0xff);
  	    pThis++;
  	}
  	fprintf(NetTrace, "\n");
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads