Commit 604785ad authored by Lehner Florian's avatar Lehner Florian

replace all remaining strcpy() with safe_strncpy()

Signed-off-by: default avatarLehner Florian <dev@der-flo.net>
parent 3a2961de
...@@ -197,7 +197,7 @@ static int arp_del(char **args) ...@@ -197,7 +197,7 @@ static int arp_del(char **args)
if (flags == 0) if (flags == 0)
flags = 3; flags = 3;
strcpy(req.arp_dev, device); safe_strncpy(req.arp_dev, device, sizeof(req.arp_dev));
/* unfortuatelly the kernel interface does not allow us to /* unfortuatelly the kernel interface does not allow us to
delete private entries anlone, so we need this hack delete private entries anlone, so we need this hack
...@@ -373,7 +373,7 @@ static int arp_set(char **args) ...@@ -373,7 +373,7 @@ static int arp_set(char **args)
/* Fill in the remainder of the request. */ /* Fill in the remainder of the request. */
req.arp_flags = flags; req.arp_flags = flags;
strcpy(req.arp_dev, device); safe_strncpy(req.arp_dev, device, sizeof(req.arp_dev));
/* Call the kernel. */ /* Call the kernel. */
if (opt_v) if (opt_v)
...@@ -560,8 +560,8 @@ static int arp_show(char *name) ...@@ -560,8 +560,8 @@ static int arp_show(char *name)
} }
/* Bypass header -- read until newline */ /* Bypass header -- read until newline */
if (fgets(line, sizeof(line), fp) != (char *) NULL) { if (fgets(line, sizeof(line), fp) != (char *) NULL) {
strcpy(mask, "-"); safe_strncpy(mask, "-", sizeof(mask));
strcpy(dev, "-"); safe_strncpy(dev, "-", sizeof(dev));
/* Read the ARP cache entries. */ /* Read the ARP cache entries. */
for (; fgets(line, sizeof(line), fp);) { for (; fgets(line, sizeof(line), fp);) {
num = sscanf(line, "%s 0x%x 0x%x %99s %99s %99s\n", num = sscanf(line, "%s 0x%x 0x%x %99s %99s %99s\n",
......
...@@ -201,7 +201,7 @@ void aftrans_def(char *tool, char *argv0, char *dflt) ...@@ -201,7 +201,7 @@ void aftrans_def(char *tool, char *argv0, char *dflt)
char *tmp; char *tmp;
char *buf; char *buf;
strcpy(afname, dflt); safe_strncpy(afname, dflt, sizeof(afname));
if (!(tmp = strrchr(argv0, '/'))) if (!(tmp = strrchr(argv0, '/')))
tmp = argv0; /* no slash?! */ tmp = argv0; /* no slash?! */
...@@ -227,7 +227,7 @@ void aftrans_def(char *tool, char *argv0, char *dflt) ...@@ -227,7 +227,7 @@ void aftrans_def(char *tool, char *argv0, char *dflt)
afname[0] = '\0'; afname[0] = '\0';
if (aftrans_opt(buf)) if (aftrans_opt(buf))
strcpy(afname, buf); safe_strncpy(afname, buf, sizeof(afname));
free(buf); free(buf);
} }
......
...@@ -111,7 +111,7 @@ static int AX25_input(int type, char *bufp, struct sockaddr *sap) ...@@ -111,7 +111,7 @@ static int AX25_input(int type, char *bufp, struct sockaddr *sap)
/* Callsign too long? */ /* Callsign too long? */
if ((i == 6) && (*bufp != '-') && (*bufp != '\0')) { if ((i == 6) && (*bufp != '-') && (*bufp != '\0')) {
strcpy(AX25_errmsg, _("Callsign too long")); safe_strncpy(AX25_errmsg, _("Callsign too long"), sizeof(AX25_errmsg));
if (_DEBUG) if (_DEBUG)
fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig); fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
errno = E2BIG; errno = E2BIG;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <unistd.h> #include <unistd.h>
#include "net-support.h" #include "net-support.h"
#include "pathnames.h" #include "pathnames.h"
#include "util.h"
/* Split the input string into multiple fields. */ /* Split the input string into multiple fields. */
...@@ -41,7 +42,7 @@ int getargs(char *string, char *arguments[]) ...@@ -41,7 +42,7 @@ int getargs(char *string, char *arguments[])
*/ */
sp = string; sp = string;
i = 0; i = 0;
strcpy(temp, string); safe_strncpy(temp, string, sizeof(temp));
ptr = temp; ptr = temp;
/* /*
......
...@@ -215,7 +215,7 @@ static int INET_rresolve(char *name, size_t len, struct sockaddr_in *sin, ...@@ -215,7 +215,7 @@ static int INET_rresolve(char *name, size_t len, struct sockaddr_in *sin,
pn->next = INET_nn; pn->next = INET_nn;
pn->host = host; pn->host = host;
pn->name = (char *) xmalloc(strlen(name) + 1); pn->name = (char *) xmalloc(strlen(name) + 1);
strcpy(pn->name, name); safe_strncpy(pn->name, name, sizeof(pn->name));
INET_nn = pn; INET_nn = pn;
return (0); return (0);
......
...@@ -103,9 +103,9 @@ static int INET6_rresolve(char *name, struct sockaddr_in6 *sin6, int numeric) ...@@ -103,9 +103,9 @@ static int INET6_rresolve(char *name, struct sockaddr_in6 *sin6, int numeric)
} }
if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
if (numeric & 0x8000) if (numeric & 0x8000)
strcpy(name, "default"); safe_strncpy(name, "default", sizeof(name));
else else
strcpy(name, "[::]"); safe_strncpy(name, "[::]", sizeof(name));
return (0); return (0);
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "pathnames.h" #include "pathnames.h"
#include "intl.h" #include "intl.h"
#include "net-features.h" #include "net-features.h"
#include "util.h"
/* neighbour discovery from linux-2.4.0/include/net/neighbour.h */ /* neighbour discovery from linux-2.4.0/include/net/neighbour.h */
...@@ -216,31 +217,31 @@ int rprint_cache6(int ext, int numeric) ...@@ -216,31 +217,31 @@ int rprint_cache6(int ext, int numeric)
/* Decode the state */ /* Decode the state */
switch (state) { switch (state) {
case NUD_NONE: case NUD_NONE:
strcpy(statestr, "NONE"); safe_strncpy(statestr, "NONE", sizeof(statestr));
break; break;
case NUD_INCOMPLETE: case NUD_INCOMPLETE:
strcpy(statestr, "INCOMPLETE"); safe_strncpy(statestr, "INCOMPLETE", sizeof(statestr));
break; break;
case NUD_REACHABLE: case NUD_REACHABLE:
strcpy(statestr, "REACHABLE"); safe_strncpy(statestr, "REACHABLE", sizeof(statestr));
break; break;
case NUD_STALE: case NUD_STALE:
strcpy(statestr, "STALE"); safe_strncpy(statestr, "STALE", sizeof(statestr));
break; break;
case NUD_DELAY: case NUD_DELAY:
strcpy(statestr, "DELAY"); safe_strncpy(statestr, "DELAY", sizeof(statestr));
break; break;
case NUD_PROBE: case NUD_PROBE:
strcpy(statestr, "PROBE"); safe_strncpy(statestr, "PROBE", sizeof(statestr));
break; break;
case NUD_FAILED: case NUD_FAILED:
strcpy(statestr, "FAILED"); safe_strncpy(statestr, "FAILED", sizeof(statestr));
break; break;
case NUD_NOARP: case NUD_NOARP:
strcpy(statestr, "NOARP"); safe_strncpy(statestr, "NOARP", sizeof(statestr));
break; break;
case NUD_PERMANENT: case NUD_PERMANENT:
strcpy(statestr, "PERM"); safe_strncpy(statestr, "PERM", sizeof(statestr));
break; break;
default: default:
snprintf(statestr, sizeof(statestr), "UNKNOWN(%02x)", state); snprintf(statestr, sizeof(statestr), "UNKNOWN(%02x)", state);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "pathnames.h" #include "pathnames.h"
#include "intl.h" #include "intl.h"
#include "net-features.h" #include "net-features.h"
#include "util.h"
extern struct aftype inet6_aftype; extern struct aftype inet6_aftype;
...@@ -63,7 +63,7 @@ static int INET6_setroute(int action, int options, char **args) ...@@ -63,7 +63,7 @@ static int INET6_setroute(int action, int options, char **args)
if (*args == NULL) if (*args == NULL)
return (usage()); return (usage());
strcpy(target, *args++); safe_strncpy(target, *args++, sizeof(target));
if (!strcmp(target, "default")) { if (!strcmp(target, "default")) {
prefix_len = 0; prefix_len = 0;
memset(&sa6, 0, sizeof(sa6)); memset(&sa6, 0, sizeof(sa6));
...@@ -112,7 +112,7 @@ static int INET6_setroute(int action, int options, char **args) ...@@ -112,7 +112,7 @@ static int INET6_setroute(int action, int options, char **args)
return (usage()); return (usage());
if (rt.rtmsg_flags & RTF_GATEWAY) if (rt.rtmsg_flags & RTF_GATEWAY)
return (usage()); return (usage());
strcpy(gateway, *args); safe_strncpy(gateway, *args, sizeof(gateway));
if (inet6_aftype.input(1, gateway, if (inet6_aftype.input(1, gateway,
(struct sockaddr *) &sa6) < 0) { (struct sockaddr *) &sa6) < 0) {
inet6_aftype.herror(gateway); inet6_aftype.herror(gateway);
...@@ -152,7 +152,7 @@ static int INET6_setroute(int action, int options, char **args) ...@@ -152,7 +152,7 @@ static int INET6_setroute(int action, int options, char **args)
} }
if (devname) { if (devname) {
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, devname); safe_strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOGIFINDEX, &ifr) < 0) { if (ioctl(skfd, SIOGIFINDEX, &ifr) < 0) {
perror("SIOGIFINDEX"); perror("SIOGIFINDEX");
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "intl.h" #include "intl.h"
#include "net-features.h" #include "net-features.h"
#include "proc.h" #include "proc.h"
#include "util.h"
extern struct aftype inet_aftype; extern struct aftype inet_aftype;
extern char *INET_sprintmask(struct sockaddr *sap, int numeric, extern char *INET_sprintmask(struct sockaddr *sap, int numeric,
...@@ -106,16 +107,16 @@ int rprint_fib(int ext, int numeric) ...@@ -106,16 +107,16 @@ int rprint_fib(int ext, int numeric)
(void) inet_aftype.input(1, mask_addr, &snet_mask); (void) inet_aftype.input(1, mask_addr, &snet_mask);
sin_netmask = (struct sockaddr_in *)&snet_mask; sin_netmask = (struct sockaddr_in *)&snet_mask;
strcpy(net_addr, INET_sprintmask(&snet_target, safe_strncpy(net_addr, INET_sprintmask(&snet_target,
(numeric | 0x8000 | (iflags & RTF_HOST? 0x4000: 0)), (numeric | 0x8000 | (iflags & RTF_HOST? 0x4000: 0)),
sin_netmask->sin_addr.s_addr)); sin_netmask->sin_addr.s_addr),
net_addr[15] = '\0'; sizeof(net_addr));
strcpy(gate_addr, inet_aftype.sprint(&snet_gateway, numeric | 0x4000)); safe_strncpy(gate_addr, inet_aftype.sprint(&snet_gateway, numeric | 0x4000),
gate_addr[15] = '\0'; sizeof(gate_addr));
strcpy(mask_addr, inet_aftype.sprint(&snet_mask, 1)); safe_strncpy(mask_addr, inet_aftype.sprint(&snet_mask, 1),
mask_addr[15] = '\0'; sizeof(mask_addr));
/* Decode the flags. */ /* Decode the flags. */
flags[0] = '\0'; flags[0] = '\0';
...@@ -125,7 +126,7 @@ int rprint_fib(int ext, int numeric) ...@@ -125,7 +126,7 @@ int rprint_fib(int ext, int numeric)
strcat(flags, "G"); strcat(flags, "G");
#if HAVE_RTF_REJECT #if HAVE_RTF_REJECT
if (iflags & RTF_REJECT) if (iflags & RTF_REJECT)
strcpy(flags, "!"); safe_strncpy(flags, "!", sizeof(flags));
#endif #endif
if (iflags & RTF_HOST) if (iflags & RTF_HOST)
strcat(flags, "H"); strcat(flags, "H");
...@@ -337,23 +338,19 @@ int rprint_cache(int ext, int numeric) ...@@ -337,23 +338,19 @@ int rprint_cache(int ext, int numeric)
/* Fetch and resolve the target address. */ /* Fetch and resolve the target address. */
(void) inet_aftype.input(1, dest_addr, &snet); (void) inet_aftype.input(1, dest_addr, &snet);
strcpy(dest_addr, inet_aftype.sprint(&snet, numeric)); safe_strncpy(dest_addr, inet_aftype.sprint(&snet, numeric), sizeof(dest_addr));
dest_addr[15] = '\0';
/* Fetch and resolve the gateway address. */ /* Fetch and resolve the gateway address. */
(void) inet_aftype.input(1, gate_addr, &snet); (void) inet_aftype.input(1, gate_addr, &snet);
strcpy(gate_addr, inet_aftype.sprint(&snet, numeric)); safe_strncpy(gate_addr, inet_aftype.sprint(&snet, numeric), sizeof(gate_addr));
gate_addr[15] = '\0';
/* Fetch and resolve the source. */ /* Fetch and resolve the source. */
(void) inet_aftype.input(1, src_addr, &snet); (void) inet_aftype.input(1, src_addr, &snet);
strcpy(src_addr, inet_aftype.sprint(&snet, numeric)); safe_strncpy(src_addr, inet_aftype.sprint(&snet, numeric), sizeof(src_addr));
src_addr[15] = '\0';
/* Fetch and resolve the SpecDst addrerss. */ /* Fetch and resolve the SpecDst addrerss. */
(void) inet_aftype.input(1, specdst, &snet); (void) inet_aftype.input(1, specdst, &snet);
strcpy(specdst, inet_aftype.sprint(&snet, numeric)); safe_strncpy(specdst, inet_aftype.sprint(&snet, numeric), sizeof(specdst));
specdst[15] = '\0';
/* Decode the flags. */ /* Decode the flags. */
flags[0] = '\0'; flags[0] = '\0';
...@@ -367,7 +364,7 @@ if (format == 1) { ...@@ -367,7 +364,7 @@ if (format == 1) {
strcat(flags, "G"); strcat(flags, "G");
#if HAVE_RTF_REJECT #if HAVE_RTF_REJECT
if (iflags & RTF_REJECT) if (iflags & RTF_REJECT)
strcpy(flags, "!"); safe_strncpy(flags, "!", sizeof(flags));
#endif #endif
if (iflags & RTF_REINSTATE) if (iflags & RTF_REINSTATE)
strcat(flags, "R"); strcat(flags, "R");
......
...@@ -414,12 +414,12 @@ int if_fetch(struct interface *ife) ...@@ -414,12 +414,12 @@ int if_fetch(struct interface *ife)
int fd; int fd;
char *ifname = ife->name; char *ifname = ife->name;
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0) if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0)
return (-1); return (-1);
ife->flags = ifr.ifr_flags; ife->flags = ifr.ifr_flags;
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) if (ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0)
memset(ife->hwaddr, 0, 32); memset(ife->hwaddr, 0, 32);
else else
...@@ -427,7 +427,7 @@ int if_fetch(struct interface *ife) ...@@ -427,7 +427,7 @@ int if_fetch(struct interface *ife)
ife->type = ifr.ifr_hwaddr.sa_family; ife->type = ifr.ifr_hwaddr.sa_family;
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFMTU, &ifr) < 0) if (ioctl(skfd, SIOCGIFMTU, &ifr) < 0)
ife->mtu = 0; ife->mtu = 0;
else else
...@@ -438,14 +438,14 @@ int if_fetch(struct interface *ife) ...@@ -438,14 +438,14 @@ int if_fetch(struct interface *ife)
ife->type == ARPHRD_SLIP6 || ife->type == ARPHRD_CSLIP6 || ife->type == ARPHRD_SLIP6 || ife->type == ARPHRD_CSLIP6 ||
ife->type == ARPHRD_ADAPT) { ife->type == ARPHRD_ADAPT) {
#ifdef SIOCGOUTFILL #ifdef SIOCGOUTFILL
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGOUTFILL, &ifr) < 0) if (ioctl(skfd, SIOCGOUTFILL, &ifr) < 0)
ife->outfill = 0; ife->outfill = 0;
else else
ife->outfill = (unsigned long) ifr.ifr_data; ife->outfill = (unsigned long) ifr.ifr_data;
#endif #endif
#ifdef SIOCGKEEPALIVE #ifdef SIOCGKEEPALIVE
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGKEEPALIVE, &ifr) < 0) if (ioctl(skfd, SIOCGKEEPALIVE, &ifr) < 0)
ife->keepalive = 0; ife->keepalive = 0;
else else
...@@ -454,20 +454,20 @@ int if_fetch(struct interface *ife) ...@@ -454,20 +454,20 @@ int if_fetch(struct interface *ife)
} }
#endif #endif
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0)
memset(&ife->map, 0, sizeof(struct ifmap)); memset(&ife->map, 0, sizeof(struct ifmap));
else else
memcpy(&ife->map, &ifr.ifr_map, sizeof(struct ifmap)); memcpy(&ife->map, &ifr.ifr_map, sizeof(struct ifmap));
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0)
memset(&ife->map, 0, sizeof(struct ifmap)); memset(&ife->map, 0, sizeof(struct ifmap));
else else
ife->map = ifr.ifr_map; ife->map = ifr.ifr_map;
#ifdef HAVE_TXQUEUELEN #ifdef HAVE_TXQUEUELEN
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(skfd, SIOCGIFTXQLEN, &ifr) < 0) if (ioctl(skfd, SIOCGIFTXQLEN, &ifr) < 0)
ife->tx_queue_len = -1; /* unknown value */ ife->tx_queue_len = -1; /* unknown value */
else else
...@@ -480,24 +480,24 @@ int if_fetch(struct interface *ife) ...@@ -480,24 +480,24 @@ int if_fetch(struct interface *ife)
/* IPv4 address? */ /* IPv4 address? */
fd = get_socket_for_af(AF_INET); fd = get_socket_for_af(AF_INET);
if (fd >= 0) { if (fd >= 0) {
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
ifr.ifr_addr.sa_family = AF_INET; ifr.ifr_addr.sa_family = AF_INET;
if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) { if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
ife->has_ip = 1; ife->has_ip = 1;
ife->addr = ifr.ifr_addr; ife->addr = ifr.ifr_addr;
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFDSTADDR, &ifr) < 0) if (ioctl(fd, SIOCGIFDSTADDR, &ifr) < 0)
memset(&ife->dstaddr, 0, sizeof(struct sockaddr)); memset(&ife->dstaddr, 0, sizeof(struct sockaddr));
else else
ife->dstaddr = ifr.ifr_dstaddr; ife->dstaddr = ifr.ifr_dstaddr;
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFBRDADDR, &ifr) < 0) if (ioctl(fd, SIOCGIFBRDADDR, &ifr) < 0)
memset(&ife->broadaddr, 0, sizeof(struct sockaddr)); memset(&ife->broadaddr, 0, sizeof(struct sockaddr));
else else
ife->broadaddr = ifr.ifr_broadaddr; ife->broadaddr = ifr.ifr_broadaddr;
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFNETMASK, &ifr) < 0) if (ioctl(fd, SIOCGIFNETMASK, &ifr) < 0)
memset(&ife->netmask, 0, sizeof(struct sockaddr)); memset(&ife->netmask, 0, sizeof(struct sockaddr));
else else
...@@ -511,7 +511,7 @@ int if_fetch(struct interface *ife) ...@@ -511,7 +511,7 @@ int if_fetch(struct interface *ife)
/* DDP address maybe ? */ /* DDP address maybe ? */
fd = get_socket_for_af(AF_APPLETALK); fd = get_socket_for_af(AF_APPLETALK);
if (fd >= 0) { if (fd >= 0) {
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) { if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
ife->ddpaddr = ifr.ifr_addr; ife->ddpaddr = ifr.ifr_addr;
ife->has_ddp = 1; ife->has_ddp = 1;
...@@ -523,22 +523,22 @@ int if_fetch(struct interface *ife) ...@@ -523,22 +523,22 @@ int if_fetch(struct interface *ife)
/* Look for IPX addresses with all framing types */ /* Look for IPX addresses with all framing types */
fd = get_socket_for_af(AF_IPX); fd = get_socket_for_af(AF_IPX);
if (fd >= 0) { if (fd >= 0) {
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (!ipx_getaddr(fd, IPX_FRAME_ETHERII, &ifr)) { if (!ipx_getaddr(fd, IPX_FRAME_ETHERII, &ifr)) {
ife->has_ipx_bb = 1; ife->has_ipx_bb = 1;
ife->ipxaddr_bb = ifr.ifr_addr; ife->ipxaddr_bb = ifr.ifr_addr;
} }
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (!ipx_getaddr(fd, IPX_FRAME_SNAP, &ifr)) { if (!ipx_getaddr(fd, IPX_FRAME_SNAP, &ifr)) {
ife->has_ipx_sn = 1; ife->has_ipx_sn = 1;
ife->ipxaddr_sn = ifr.ifr_addr; ife->ipxaddr_sn = ifr.ifr_addr;
} }
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (!ipx_getaddr(fd, IPX_FRAME_8023, &ifr)) { if (!ipx_getaddr(fd, IPX_FRAME_8023, &ifr)) {
ife->has_ipx_e3 = 1; ife->has_ipx_e3 = 1;
ife->ipxaddr_e3 = ifr.ifr_addr; ife->ipxaddr_e3 = ifr.ifr_addr;
} }
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (!ipx_getaddr(fd, IPX_FRAME_8022, &ifr)) { if (!ipx_getaddr(fd, IPX_FRAME_8022, &ifr)) {
ife->has_ipx_e2 = 1; ife->has_ipx_e2 = 1;
ife->ipxaddr_e2 = ifr.ifr_addr; ife->ipxaddr_e2 = ifr.ifr_addr;
...@@ -550,7 +550,7 @@ int if_fetch(struct interface *ife) ...@@ -550,7 +550,7 @@ int if_fetch(struct interface *ife)
/* Econet address maybe? */ /* Econet address maybe? */
fd = get_socket_for_af(AF_ECONET); fd = get_socket_for_af(AF_ECONET);
if (fd >= 0) { if (fd >= 0) {
strcpy(ifr.ifr_name, ifname); safe_strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) { if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
ife->ecaddr = ifr.ifr_addr; ife->ecaddr = ifr.ifr_addr;
ife->has_econet = 1; ife->has_econet = 1;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "net-support.h" #include "net-support.h"
#include "pathnames.h" #include "pathnames.h"
#include "intl.h" #include "intl.h"
#include "util.h"
/* UGLY */ /* UGLY */
...@@ -72,15 +73,15 @@ int IPX_rprint(int options) ...@@ -72,15 +73,15 @@ int IPX_rprint(int options)
/* Fetch and resolve the Destination */ /* Fetch and resolve the Destination */
(void) ap->input(5, net, &sa); (void) ap->input(5, net, &sa);
strcpy(net, ap->sprint(&sa, numeric)); safe_strncpy(net, ap->sprint(&sa, numeric), sizeof(net));
/* Fetch and resolve the Router Net */ /* Fetch and resolve the Router Net */
(void) ap->input(5, router_net, &sa); (void) ap->input(5, router_net, &sa);
strcpy(router_net, ap->sprint(&sa, numeric)); safe_strncpy(router_net, ap->sprint(&sa, numeric), sizeof(router_net));
/* Fetch and resolve the Router Node */ /* Fetch and resolve the Router Node */
(void) ap->input(2, router_node, &sa); (void) ap->input(2, router_node, &sa);
strcpy(router_node, ap->sprint(&sa, numeric)); safe_strncpy(router_node, ap->sprint(&sa, numeric), sizeof(router_node));
printf("%-25s %-25s %-25s\n", net, router_net, router_node); printf("%-25s %-25s %-25s\n", net, router_net, router_node);
} }
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "net-support.h" #include "net-support.h"
#include "pathnames.h" #include "pathnames.h"
#include "intl.h" #include "intl.h"
#include "util.h"
#ifndef _NETROSE_ROSE_H #ifndef _NETROSE_ROSE_H
#include <linux/ax25.h> #include <linux/ax25.h>
...@@ -83,7 +84,7 @@ static int ROSE_input(int type, char *bufp, struct sockaddr *sap) ...@@ -83,7 +84,7 @@ static int ROSE_input(int type, char *bufp, struct sockaddr *sap)
/* Node address the correct length ? */ /* Node address the correct length ? */
if (strlen(bufp) != 10) { if (strlen(bufp) != 10) {
strcpy(ROSE_errmsg, _("Node address must be ten digits")); safe_strncpy(ROSE_errmsg, _("Node address must be ten digits"), sizeof(ROSE_errmsg));
errno = EINVAL; errno = EINVAL;
return (-1); return (-1);
} }
......
...@@ -235,7 +235,7 @@ int main(int ac, char **av) ...@@ -235,7 +235,7 @@ int main(int ac, char **av)
usage(); usage();
if (strlen(av[optind])+1>IFNAMSIZ) if (strlen(av[optind])+1>IFNAMSIZ)
complain(_("interface name `%s' too long"), av[optind]); complain(_("interface name `%s' too long"), av[optind]);
strcpy(ch->ifname, av[optind]); safe_strncpy(ch->ifname, av[optind], sizeof(ch->ifname));
optind++; optind++;
sprintf(pos,_("argument %d"),optind); sprintf(pos,_("argument %d"),optind);
addchange(av[optind], ch, pos); addchange(av[optind], ch, pos);
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include "intl.h" #include "intl.h"
#include "pathnames.h" #include "pathnames.h"
#include "version.h" #include "version.h"
#include "util.h"
#define DFLT_AF "inet" #define DFLT_AF "inet"
...@@ -136,9 +137,9 @@ int main(int argc, char **argv) ...@@ -136,9 +137,9 @@ int main(int argc, char **argv)
/* getopts and -net wont work :-/ */ /* getopts and -net wont work :-/ */
for (tmp = argv; *tmp; tmp++) { for (tmp = argv; *tmp; tmp++) {
if (!strcmp(*tmp, "-net")) if (!strcmp(*tmp, "-net"))
strcpy(*tmp, "#net"); safe_strncpy(*tmp, "#net", sizeof(*tmp));
else if (!strcmp(*tmp, "-host")) else if (!strcmp(*tmp, "-host"))
strcpy(*tmp, "#host"); safe_strncpy(*tmp, "#host", sizeof(*tmp));
} }
/* Fetch the command-line arguments. */ /* Fetch the command-line arguments. */
......
...@@ -621,7 +621,7 @@ main(int argc, char *argv[]) ...@@ -621,7 +621,7 @@ main(int argc, char *argv[])
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
strcpy(path_buf, ""); safe_strncpy(path_buf, "", sizeof(path_buf));
path_dev = path_buf; path_dev = path_buf;
/* Scan command line for any arguments. */ /* Scan command line for any arguments. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment