host[(sizeof host) - 1] = 0; strncpy(host, name, (sizeof host) - 1);
safe_strncpy(host, name, (sizeof host));
static int arp_show(char *name){    char host[100];    struct sockaddr sa;    char ip[100];    char hwa[100];    char mask[100];    char line[200];    char dev[100];    int type, flags;    FILE *fp;    char *hostname;    int num, entries = 0, showed = 0;    host[0] = '\0';    if (name != NULL) {	/* Resolve the host name. */	host[(sizeof host) - 1] = 0;	strncpy(host, name, (sizeof host) - 1);	if (ap->input(0, host, &sa) < 0) {	    ap->herror(host);	    return (-1);	}	strcpy(host, ap->sprint(&sa, 1));    }    /* Open the PROCps kernel table. */    if ((fp = fopen(_PATH_PROCNET_ARP, "r")) == NULL) {	perror(_PATH_PROCNET_ARP);	return (-1);    }    /* Bypass header -- read until newline */    if (fgets(line, sizeof(line), fp) != (char *) NULL) {	strcpy(mask, "-");	strcpy(dev, "-");	/* Read the ARP cache entries. */	for (; fgets(line, sizeof(line), fp);) {	    num = sscanf(line, "%s 0x%x 0x%x %100s %100s %100s\n",			 ip, &type, &flags, hwa, mask, dev);	    if (num < 4)		break;	    entries++;	    /* if the user specified hw-type differs, skip it */	    if (hw_set && (type != hw->type))		continue;	    /* if the user specified address differs, skip it */	    if (host[0] && strcmp(ip, host))		continue;	    /* if the user specified device differs, skip it */	    if (device[0] && strcmp(dev, device))		continue;	    showed++;	    /* This IS ugly but it works -be */	    if (opt_n)		hostname = "?";	    else {		if (ap->input(0, ip, &sa) < 0)		    hostname = ip;		else		    hostname = ap->sprint(&sa, opt_n | 0x8000);		if (strcmp(hostname, ip) == 0)		    hostname = "?";	    }	    if (opt_e)		arp_disp_2(hostname[0] == '?' ? ip : hostname, type, flags, hwa, mask, dev);	    else		arp_disp(hostname, ip, type, flags, hwa, mask, dev);	}    }    if (opt_v)	printf(_("Entries: %d\tSkipped: %d\tFound: %d\n"), entries, entries - showed, showed);    if (!showed) {	if (host[0] && !opt_a)	    printf("%s (%s) -- no entry\n", name, host);	else if (hw_set || host[0] || device[0]) {	    printf(_("arp: in %d entries no match found.\n"), entries);	}    }    (void) fclose(fp);    return (0);}