[net.bugs.4bsd] telnet dumps core

nowicki@sun.uucp (Bill Nowicki) (08/21/86)

Description:
        The telnet program (both 4.2BSD and 4.3BSD versions) dumps
        core when run on machines that do not allow referencing a NULL 
        pointer.

Repeat-By:
        Run the "telnet" program, and type a space followed by return.
        Or type "conn" followed by two returns.  If you are on a machine
        that does not allow refencing NULL pointers, then you get a core 
        dump crash.

sun% telnet
telnet>                 [ typed space followed by return ]
Segmentation fault (core dumped)
sun% telnet
telnet> open
(to)                    [ typed return ]
Segmentation fault (core dumped)
sun%

Fix:
*** telnet.c.fixed      Wed Aug 20 12:35:14 1986
--- /arch/4.3/usr/src/ucb/telnet.c      Tue May 27 09:47:07 1986
***************
*** 2025,2031 ****
                makeargv();
                argc = margc;
                argv = margv;
-               if (argv[1]==NULL) return 0;
        }
        if (argc > 3) {
                printf("usage: %s host-name [port]\n", argv[0]);
--- 2025,2030 ----
***************
*** 2278,2286 ****
                                quit();
                        break;
                }
!               makeargv();
!               if (margv[0] == NULL)
                        break;
                c = getcmd(margv[0]);
                if (c == Ambiguous(struct cmd *)) {
                        printf("?Ambiguous command\n");
--- 2277,2285 ----
                                quit();
                        break;
                }
!               if (line[0] == 0)
                        break;
+               makeargv();
                c = getcmd(margv[0]);
                if (c == Ambiguous(struct cmd *)) {
                        printf("?Ambiguous command\n");
*** /arch/4.3/usr/src/ucb/telnet.c      Tue May 27 09:47:07 1986
--- telnet.c.fixed      Wed Aug 20 12:35:14 1986
***************
*** 2025,2030 ****
--- 2025,2031 ----
                makeargv();
                argc = margc;
                argv = margv;
+               if (argv[1]==NULL) return 0;
        }
        if (argc > 3) {
                printf("usage: %s host-name [port]\n", argv[0]);
***************
*** 2277,2285 ****
                                quit();
                        break;
                }
-               if (line[0] == 0)
-                       break;
                makeargv();
                c = getcmd(margv[0]);
                if (c == Ambiguous(struct cmd *)) {
                        printf("?Ambiguous command\n");
--- 2278,2286 ----
                                quit();
                        break;
                }
                makeargv();
+               if (margv[0] == NULL)
+                       break;
                c = getcmd(margv[0]);
                if (c == Ambiguous(struct cmd *)) {
                        printf("?Ambiguous command\n");