temp files should be protected; bug report 4.3BSD/usr.bin/186
[unix-history] / usr / src / usr.bin / netstat / route.c
index 6e66559..e9c41e8 100644 (file)
@@ -1,12 +1,23 @@
 /*
 /*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * Copyright (c) 1983, 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)route.c    5.11 (Berkeley) 87/08/29";
-#endif
+static char sccsid[] = "@(#)route.c    5.14 (Berkeley) %G%";
+#endif /* not lint */
 
 #include <stdio.h>
 #include <strings.h>
 
 #include <stdio.h>
 #include <strings.h>
@@ -141,7 +152,7 @@ again:
                        read(kmem, (char *)&ifnet, sizeof (ifnet));
                        klseek(kmem, (off_t)ifnet.if_name, 0);
                        read(kmem, name, 16);
                        read(kmem, (char *)&ifnet, sizeof (ifnet));
                        klseek(kmem, (off_t)ifnet.if_name, 0);
                        read(kmem, name, 16);
-                       printf(" %s%d\n", name, ifnet.if_unit);
+                       printf(" %.15s%d\n", name, ifnet.if_unit);
                        m = mb.m_next;
                }
        }
                        m = mb.m_next;
                }
        }
@@ -159,7 +170,7 @@ routename(in)
        struct in_addr in;
 {
        register char *cp;
        struct in_addr in;
 {
        register char *cp;
-       static char line[50];
+       static char line[MAXHOSTNAMELEN + 1];
        struct hostent *hp;
        static char domain[MAXHOSTNAMELEN + 1];
        static int first = 1;
        struct hostent *hp;
        static char domain[MAXHOSTNAMELEN + 1];
        static int first = 1;
@@ -185,7 +196,7 @@ routename(in)
                }
        }
        if (cp)
                }
        }
        if (cp)
-               strcpy(line, cp);
+               strncpy(line, cp, sizeof(line) - 1);
        else {
 #define C(x)   ((x) & 0xff)
                in.s_addr = ntohl(in.s_addr);
        else {
 #define C(x)   ((x) & 0xff)
                in.s_addr = ntohl(in.s_addr);
@@ -205,7 +216,7 @@ netname(in, mask)
        u_long mask;
 {
        char *cp = 0;
        u_long mask;
 {
        char *cp = 0;
-       static char line[50];
+       static char line[MAXHOSTNAMELEN + 1];
        struct netent *np = 0;
        u_long net;
        register i;
        struct netent *np = 0;
        u_long net;
        register i;
@@ -241,7 +252,7 @@ netname(in, mask)
                        cp = np->n_name;
        }       
        if (cp)
                        cp = np->n_name;
        }       
        if (cp)
-               strcpy(line, cp);
+               strncpy(line, cp, sizeof(line) - 1);
        else if ((i & 0xffffff) == 0)
                sprintf(line, "%u", C(i >> 24));
        else if ((i & 0xffff) == 0)
        else if ((i & 0xffffff) == 0)
                sprintf(line, "%u", C(i >> 24));
        else if ((i & 0xffff) == 0)