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");