=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/netstat/inet.c,v retrieving revision 1.22 retrieving revision 1.23 diff -c -r1.22 -r1.23 *** src/usr.bin/netstat/inet.c 1997/11/09 16:33:09 1.22 --- src/usr.bin/netstat/inet.c 1998/02/27 12:07:33 1.23 *************** *** 1,4 **** ! /* $OpenBSD: inet.c,v 1.22 1997/11/09 16:33:09 provos Exp $ */ /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: inet.c,v 1.23 1998/02/27 12:07:33 deraadt Exp $ */ /* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */ /* *************** *** 38,44 **** #if 0 static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94"; #else ! static char *rcsid = "$OpenBSD: inet.c,v 1.22 1997/11/09 16:33:09 provos Exp $"; #endif #endif /* not lint */ --- 38,44 ---- #if 0 static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94"; #else ! static char *rcsid = "$OpenBSD: inet.c,v 1.23 1998/02/27 12:07:33 deraadt Exp $"; #endif #endif /* not lint */ *************** *** 454,460 **** static int first; static struct rpcnams *rpcn; struct rpcnams *n; ! char num[10]; if (first == 0) { first = 1; --- 454,460 ---- static int first; static struct rpcnams *rpcn; struct rpcnams *n; ! char num[20]; if (first == 0) { first = 1; *************** *** 490,496 **** if (rpc) n->rpcname = strdup(rpc->r_name); else { ! sprintf(num, "%ld", head->pml_map.pm_prog); n->rpcname = strdup(num); } } --- 490,497 ---- if (rpc) n->rpcname = strdup(rpc->r_name); else { ! snprintf(num, sizeof num, "%ld", ! head->pml_map.pm_prog); n->rpcname = strdup(num); } } *************** *** 519,535 **** int proton; int width; ! sprintf(line, "%.*s.", (Aflag && !nflag) ? 12 : 16, inetname(in)); cp = strchr(line, '\0'); if (!nflag && port) sp = getservbyport((int)port, proto); if (sp || port == 0) ! sprintf(cp, "%.8s", sp ? sp->s_name : "*"); else if (local && !nflag && (nam = getrpcportnam(ntohs(port), (strcmp(proto, "tcp") == 0 ? IPPROTO_TCP : IPPROTO_UDP)))) ! sprintf(cp, "%d[%.8s]", ntohs(port), nam); else ! sprintf(cp, "%d", ntohs(port)); width = Aflag ? 18 : 22; printf(" %-*.*s", width, width, line); } --- 520,539 ---- int proton; int width; ! snprintf(line, sizeof line, "%.*s.", (Aflag && !nflag) ? 12 : 16, ! inetname(in)); cp = strchr(line, '\0'); if (!nflag && port) sp = getservbyport((int)port, proto); if (sp || port == 0) ! snprintf(cp, line + sizeof line - cp, "%.8s", ! sp ? sp->s_name : "*"); else if (local && !nflag && (nam = getrpcportnam(ntohs(port), (strcmp(proto, "tcp") == 0 ? IPPROTO_TCP : IPPROTO_UDP)))) ! snprintf(cp, line + sizeof line - cp, "%d[%.8s]", ! ntohs(port), nam); else ! snprintf(cp, line + sizeof line - cp, "%d", ntohs(port)); width = Aflag ? 18 : 22; printf(" %-*.*s", width, width, line); } *************** *** 579,592 **** } } if (inp->s_addr == INADDR_ANY) ! strcpy(line, "*"); else if (cp) ! strcpy(line, cp); else { inp->s_addr = ntohl(inp->s_addr); #define C(x) ((x) & 0xff) ! sprintf(line, "%u.%u.%u.%u", C(inp->s_addr >> 24), ! C(inp->s_addr >> 16), C(inp->s_addr >> 8), C(inp->s_addr)); } return (line); } --- 583,597 ---- } } if (inp->s_addr == INADDR_ANY) ! snprintf(line, sizeof line, "*"); else if (cp) ! snprintf(line, sizeof line, "%s", cp); else { inp->s_addr = ntohl(inp->s_addr); #define C(x) ((x) & 0xff) ! snprintf(line, sizeof line, "%u.%u.%u.%u", ! C(inp->s_addr >> 24), C(inp->s_addr >> 16), ! C(inp->s_addr >> 8), C(inp->s_addr)); } return (line); }